1. Identifiers
The so-called identifiers are names of variables, arrays, functions, etc.
The naming of identifiers requires following a certain naming convention
2. Naming rules are divided into two categories: rigid requirements, soft requirements
The so-called rigid requirements, means that must be observed, if not complied with, even the program can not run
Soft requirements: Not required to comply with, but is an unwritten rule of the industry
mandatory Requirements specific rules :
Consists of letters, numbers, underscores, and $, but cannot start with numbers
Disable the use of keywords and reserved words inside ES
Case sensitive
Soft Requirements : hope to know the meaning of the text
You can tell what this identifier means by using an identifier name.
naming laws :
Hump nomenclature : The Hump naming method is divided into two kinds: the big Hump and the small hump . The so-called Big Hump (Pascal nomenclature) means that each word is capitalized, for example: UserName the so-called small hump, the first letter lowercase, and the first letter of the following words for example: UserName
Hungarian nomenclature :
The so-called Hungarian nomenclature is made up of one or more words, preceded by a fixed prefix
Array (arrays) A_myuser
Boolean (Boolean) b_ispassed
function (functions) fn_dosth
Object (objects) O_person
Snake Name method
The so-called serpentine nomenclature refers to the use of underscores to separate each word.
User_name User_password
3. The comments inside ES
There are two types of annotations, one single-line comment and the other a multiline comment
single-line comment : Starts with two slashes
Multiline Comment : Start with/* and end with */
4. Strict mode
Starting with ES5, a reference to something called strict mode. As the name implies, is more stringent, in this mode, will reduce the ambiguity of the syntax, and parsing faster. Also, the syntax supported under strict mode can often be seen as the reference standard for the next version.
How to enter strict mode
"Use Strict"
5. JS statement
Like most programming languages, they end with semicolons, but this is not a must
Although semicolons can be omitted, they are not recommended. Because the compressed file compresses the code, it can cause code errors if there is no semicolon.
6. Keywords and reserved words
Keywords: the so-called keyword, refers to the ES inside the predefined identifiers, you can not use these keywords when you name
Keywords (ES5 for example) are : Break/do/instanced/typeof/case/else/new/var/catch/finanly/return/void/continue/for/switch /while/debugger/function/this/with/default/if/throw/delete/in/try
reserved Words (ES5 for example) are : abstrac/enum/int/short/boolean/export/interface/static/byte/extends/long/super/char/final /native/synchronized/class/float/package/throes/const/goto/private
/transient/debugger/implements/protected/volatile/double/import/public
JS Syntax Basics