JavaScript Learning Summary First day

Source: Internet
Author: User
Tags script tag

JavaScript basics

I. Features of JavaScript

    1. Browser scripting language, which can be mixed with HTML code

    2. Superior Cross-platform performance and can be written on Windows.linux

    3. Good security

    4. Good compatibility

Two. Javascrpt has three major learning objectives

    1. Effects

    2. Form validation

    3. Ajax

Three. JavaScript Basic syntax

There are four types of JavaScript usage scenarios

    1. Script tag

      <script type= "text/javascript" >

      Alert (' Hello ')//alert display content in the page bounce box

      <script>

    2. Externally introduced script tag, requires SRC attribute

2.1 Create File 1.js

2.2 Introducing 1.js effects files through the script tag in the main HTML file

<script type= "text/javascript src=" ./1.js></script>

./represents the current directory with absolute path and relative path notation

3. Element Event Properties

<button onclick= ' func () > button </button> <script type= "text/javascript" > function func () {alert ('    Button Trigger '); } <script>

The Func () function is triggered by clicking on the button box and clicking the onclick action, which implements the alert () Effect.

href attribute of the 4.a tag

Declare a variable var variable name for example: var a = 1; Declaring a variable is 1

<a href= "javascript:var A=10;var b=10;alert (a+b);" > Connectivity </a>

Four. variables are declarations

    1. The declaration of a variable can be made up of alphanumeric underscores

    2. The first letter cannot be a number.

    3. JavaScript is very strictly case-sensitive

    4. And can't keyword, here's the keyword For example can't make JavaScript built-in function name

Five. notes

Commented content, in the final page display is not visible, easy for developers to see the code description, but also for other people to watch, you can view the Web page source code to watch

Single-line comment//content

Multiline comment/* content */

Six. data type

    1. Classification of data types

Boolean (boolean) string (string) number (numeric Type) object (object) function undefined

The number numeric type, which is shaped and floating in php, is collectively referred to as a numeric type in javascript, so the Nember type contains a shape that also contains a floating point type, and a special Nan with no numeric value.

nan, and any numeric operation, results in a value of Nan.

When any value is compared to nan, the returned result is False. (! = And!==) The returned result is true

When detecting whether a value is nan, you can use the isNaN function

Oject object that contains the Newobject.newarray,null

Seven. Data type Conversion

    1. Data type conversions are divided into forced type conversions and automatic type conversions

      1.1 Coercion of type conversions:

      There are three conversions of numbers

      Parseint: if it is a pure value, the value returned is directly a numeric type,

      If the first letter is a number, it is truncated to the first digit that is not the number returned

      If the first letter is not a number, return Nan

      Parsefloat: the law of transformation and parseint consistent

      Number: pure numbers are converted to pure digits, and if there are non-numbers in the middle, return nan directly (true = 1 false = 0)

      1.1 Convert to String

      string conversion via string, e.g. ' 123 ' after string (123) conversion

      1.3 Convert to Boolean Boolean

2.1 Automatic type Conversion Primary if () the contents inside parentheses are automatically converted to true and false

Nan means note a number, which detects whether the Nan type is IsNaN

A string of numbers and letters, converted to int, only to the digital stage

Such as: var a= ' 200abc ';

var z = parseint (a);

z=200 parsefloat

Case with conversion to false

0,0.0, ', ' 0 ', null,new Array (), undefined,nan,false,function () {}

Eight. operators

Main content: arithmetic \ assignment \ comparison \ logical \ bit \ other \ string Connection (+)

Strings are concatenated in Php.

In JavaScript string connection with +

As 100+ ' 200 ' equals the result is 10200

100+200 equals the result is 300

100+200+ ' 300 ' turns out to be 300300.

' 10 ' + (2+1); The result is 103 in Parentheses.

NINE. Process Control

If () {}

else if () {} in JavaScript there is a space between else if

Switch () detection value is equal to perform

10. Cyclic Structure

1.for

2.while

3.do...while

4.break

5.continue

This article is from the "bitter php" blog, please be sure to keep this source http://haibobo.blog.51cto.com/4799843/1941971

JavaScript Learning Summary First day

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.