This is the JS Advanced Program Design Study notes, notes I learn some of JS's experience of the demo, like a friend can directly refer to the original book "JavaScript Advanced Programming", the purpose of writing a note is easy to error in JS, difficult to understand the place to make a note, so as not to continue to trample the pit later.
1. Grammar
- Case-sensitive: for example, typeof is used to test data types, unlike TypeOf, a Func can be defined as typeof
- Identifier: The first character must be a letter, underscore, or $, followed by a number, letter, underscore, or $; identifiers cannot use System keywords and reserved words such as Var, true, false, NULL, let, etc.
- Strict mode:
Strict mode is the concept introduced in ECMAScript 5, is a mechanism for the definition of JS and execution model, but also to be compatible with the old version of the ECMAScript version of the introduction, is a kind of compilation instructions, you can determine the ECMAScript 3 version of the compilation runtime of some of the indeterminate behavior. Using "Use strict", the method is as follows:
function say () { "use strict"; Console.log ("Hello strict mode");} Say ();
2. Variables
- All uninitialized variables are always undefined, regardless of the variable type:
function say () { var message = "Hello message";} Say (); alert (message); Message is not defined as undefined
However, if the VAR keyword is omitted, the message automatically rises to a global variable without error:
function say () { = "Hello message";} Say (); Console.log (message);
Results:
- The initialization of variable declarations allows simultaneous, such as:
var m1 = "1", M2 = "2", M3 = [];console.log (M1); Console.log (m2) ; Console.log (m3);
JS Programming 01--Basic Concepts