Article From:https://www.cnblogs.com/LaneCheung/p/9122291.html

Contents

3.1.2 identifier”

Identifiers refer to variables, functions, names of attributes, or parameters of functions. Identifiers can be one or more characters combined in the following format rules:

  • The first character must be oneLetterUnderlineOr aDollar sign ($)
  • Other characters can beLetterUnderlineDollar signornumber

3.1.3 writing style”

According to convention, the ECMAScript identifier is humped uppercase, that is, the first letter lowercase, and the first letter of each remaining word is capitalized, for example:

firstSecond

myCar

doSomethingImportant

3.1.4 Annotation”

ECMAScript Use C style annotations, including single line annotation and block level annotation. The single line commentary starts with two slashes, as shown below.

// Single-Line Comments

Block – level annotations with a slash and an asterisk (/)At the beginning, with an asterisk and a slash (/)At the end, the following is shown as follows:

/*
* This is a multi - line
* (Block level annotation
*/

Although the second and third lines in the above annotation begin with an asterisk, this is not necessary. The two asterisk is added solely to improve the readability of annotations.

3.1.5 strict model”

ECMAScript 5 A strict model is introduced.strict mode)The concept. The strict mode is to define a different parsing and executing model for JavaScript. Under strict mode, some uncertain behaviors in ECMAScript 3 will be processed, and some unsafe operations will also be thrown wrong. To be in the entire scriptWith strict mode, you can add the following code at the top:

"use strict";

This line of code looks like a string and does not assign any value to any variable, but it is actually a compilation instruction (pragma) to tell the supported JavaScript engine to switch to a strict mode. This is to choose not to destroy the ECMAScript 3 syntax.Definite grammar. Including the compilation instruction above the function, you can also specify that the function is executed in strict mode:

function doSomething(){
    "use strict";
    //Function body
}

In strict mode, the execution result of JavaScript will be very different, so this book will always point out the difference in strict mode. Browsers supporting strict mode include IE10+, Firefox 4+, Safari 5.1+, Opera.12+ and Chrome.

Similar Posts:

Link of this Article: 3.1 basic grammar