JavaScript Learning Note III: Basic Concepts (1)

Source: Internet
Author: User

1. Everything in JS (variables, function names, operators, etc.) is case-sensitive. --true is a Boolean value, and true is just an identifier.

2. The JS statement ends with a semicolon, but is not required for the reason:

A. No semicolon at the end can sometimes cause compression errors.

B. A semicolon, in some cases, makes it easier for the parser to improve the performance of the code.

3. Different ECMAScript versions have different definitions for keywords and reserved words, but it is best to never use any keywords or reserved words in the JS code in order to be compatible with future versions of ECMAScript.

4. The ECMAScript variable is loosely typed, that is, a variable has no specific type restrictions and can hold any type of data. A variable that has not been initialized will hold a special value of--undefined.

5. The variable defined by the var operator becomes a local variable in the scope that defines the variable. If the variable defined by VAR is not within any statement block, it is a global variable. It is also possible to define global variables directly in the block of statements by omitting Var, but this practice is not recommended, it is easier to cause confusion and is not conducive to maintenance.

6. There are 5 simple data types (basic types) in ECMAScript: Undefined, Null, Boolean, number, String. There is also a complex data type: Object.

7. typeof is used to detect the data type of a given variable.

8. Execution of typeof on uninitialized or undeclared variables will return undefined. The undefined value is actually derived from a null value. therefore null = = undefined.

9. A Boolean value of true does not necessarily equal 1, and false does not necessarily equal 0. The values that are equivalent to False are: false, "", 0, NaN, null, undefined, and the rest of the values are equivalent to true.

10. The highest precision of a floating-point value is 17 decimal places, but it is far less accurate than an integer in arithmetic calculations, so never test a particular floating-point value. For example a=0.1,b=0.2, but a+b! = 0.3.

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

JavaScript Learning Note III: Basic Concepts (1)

Related Article

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.