1. Identifiers and keywords
An identifier starts with a letter and can contain letters, numbers, and underscores. The following reserved characters cannot be used for identifiers:
Copy codeThe Code is as follows: abstract, boolean, break, byte, case, catch, char, class, const, debugger, default, delete, do, double, else, enum, export, extends, false, final, finally, float, for, function, goto, if, implements, import, in, instanceof, int, interface, long, native, new, null, package, private, protected, public, return, short, static, super, switch, synchronized, this, throw, throws, transient, true, try, typeof, var, volatile, void, while,
In addition, undefined, NaN, and Infinity have specific meanings in javascript, so do not use them either. Javascript does not allow the use of reserved words to name variables or parameters. In addition, javascript does not allow the attribute name of an object to be stored in the literal volume of the object, or after the dot of an attribute access expression, the reserved word field is used.
2. Number
Javascript only has a single numeric type, which is represented as a 64-bit floating point number internally, the same as java's double.
The value NaN is a numeric value that indicates an operation result that cannot produce normal results. NaN is not equal to any value, including itself. You can use the isNaN (number) function to detect NaN.
The Infinity value indicates all values greater than 1.7976931348623157E + 308, that is, the Infinity value.
3. String
The string is unchangeable. Create a New String object for each string change.
The string contains Unicode 16 characters. Javascript has no character type.
A string has a length attribute to obtain the length of a string.
4. Statements
When a variable is defined in a function in a var statement, the defined variable is the private variable of the function. The var statement does not use variables defined by var outside the function or in the function (for example, function () {m = 3.
The code block in javascript does not create a new scope. Therefore, variables should be defined at the top of the function, rather than in the code block.
For... In... The statement can enumerate all attribute names of an object. Generally, you must check object. hasOwnProperty (varible) to determine whether the property name is a member of the object or found from its prototype chain.
For (var pro in Object) {if (Object. hasOwnProperty (pro )){...};}
5. the following values are treated as false: false, null, undefined, empty string "", number 0, and number NaN.