1. Identifiers and reserved words
Identifiers: Typically variable names, which can consist of numbers & letters &$& underscores; The first character cannot be a number;
Reserved words: Typically a word that has a special meaning inside JavaScript, or a new property or method that is about to be added, not when the identifier name is used;
2. Notes
JavaScript annotations fall into two categories:
The contents of a single line comment//comment
The contents of a multiline comment/* Comment */
The Code compression tool does not delete this comment when a multiline comment is written as the content of the/*! comment * *;
3. Strict mode
Add ' use static ' at the beginning of the function or document; can open strict mode, it is recommended to open strict mode, develop good coding habits;
If the browser does not support strict mode, the line is automatically ignored;
* in strict mode, you cannot assign values to undeclared variables and do not support with syntax;
4. Variables
Variables are divided into global variables and local variables, which can generally be accessed by using window. Variable names are the global variables that all functions can access;
Declared inside the function body, only variables that can be accessed inside the function are local variables;
Variables are declared with the keyword Var, for example varage; You can assign values to variables at the same time as variable declarations, for example:var age =Max;
Constants, there is no concept of constants in JavaScript, the general Convention is to capitalize all the identifiers of constants for example: var age =;
5.type
Variables are divided into: numbers, strings, booleans, arrays, functions, objects, date objects, RegEXP;
How to identify the type of the variable, generally using the operator typeof variable name, but the typeof operator returns the result is not accurate; You can use the following function to identify the type of the variable;
function type (obj) { // return value is lowercase number, string, Boolean, array, function, object, date, regexp, Undefined, nu ll; return Object.prototype.toString.call (obj). Slice (8,-1). toLowerCase (); }
6.null && undefined
Null indicates that there is no;
Undefined indicates existence but no value;
Returns True when the = = comparison is used;
JavaScript basic Syntax &1