JavaScript Essays (1)

Source: Internet
Author: User

Delay script

HTML4.01 defines the defer property for the <script> tag. The script will be deferred until the entire page is resolved and then run.

Example: <script type= "Text/javascript" defer= "defer" scr= "Test1.js" ><script>

* Deferred scripts are not necessarily executed sequentially, so it is best to include only one deferred script

The Defer property applies only to external script files.

Strict mode

"User Strict"

Variable

Although it is possible to define global variables by omitting the VAR operator, this is not a recommended practice. Because defining global variables in local functions is difficult to maintain, and if the Var operator is deliberately ignored, it can cause unnecessary confusion because the variable is not immediately defined.

Type

There are 5 simple data types (also called basic data Types) in ECMAScript: Undefined, Null, Boolean, number and string, and a complex data type Object

typeof operator

The data type used to detect a given variable

typeof (Message) or typeof message * parentheses are not required

Undefined when declaring a variable with VAR but not initializing it, the value of this variable is Undefined

Null

If the defined variable is intended to be used for saving the object in the future, it is better to initialize the variable to null instead of the other value (because the null typeof value is Object)

*alert (null==undefined); True

Number

Leading 0 will be ignored, and subsequent values will be interpreted as decimal

If the floating-point number itself represents an integer (such as 1.0) then the value is also converted to an integer

NaN

A condition that represents an operand that would have returned a numeric value that did not return a number

Nan is not equal to any value, including the Nan itself.

IsNaN

Any value that cannot be converted to a number will cause this function to return true

numeric conversions

There are 3 functions that can convert a non-numeric value to a value of 1. Number () 2.parseInt () 3.parseFloat ()

The first function number () can be used for any data type, while the other two functions are specifically used to convert a string to a numeric value.

Number () If the value to convert is Underfine, return Nan

parseint () ignores whitespace in front of the string. If the first character is not a numeric character or a minus sign, parseint () returns Nan.

JavaScript Essays (1)

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.