Grammar Rules
(1) JavaScript is not sensitive to line, indent, and space.
Note: Each statement ends with a semicolon, although the semicolon is not mandatory, but for the program to be compressed in the future, if not semicolon, after compression will not run.
(2) All the symbols are in English. such as parentheses , quotation marks, semicolons.
(3) JavaScript comments:
// single-line comment
/* This is a multi-line comment */
Note: In sublime, the shortcut key for a single-line comment is ctrl+/
that the shortcut key for a multiline comment is ctrl+shift+/
.
variable naming rules:
Strictly case-sensitive
-names can appear with letters, numbers, underscores, $, but not numbers, or pure numbers
-Cannot contain keywords and reserved words.
Keyword: var number
In addition to the keyword top name try not to use it.
-Recommended Hump nomenclature: when there are several meaningful words that make up the name, the first letter is lowercase and the remaining words are written in the first letter.
-Hungarian name: It is based on the first character of the data type Word as a prefix
Data type:
Data types include: basic data types and reference data types
The base data type refers to simple data segments, which refer to objects that have multiple values.
1. Basic data types1.1 Number
var a = 123; // typeof Check what the current variable is data type console.log (typeof a)// special case var a1 = 5/0; Console.log (typeof//Infinity infinitely large. Number Type
1.2 String
var str = ' 123 'console.log (typeof str)
1.3 Boolean
var false ; Console.log (typeof B1) // in JS, all data types are converted to the Boolean type. 0,nan,underfined and False are false, others are true
1.4 Null
var null; // empty objects. Object Console.log (C1) // NULL is an object
1.5 undefined
var D1; // indicates that the variable is undefined console.log (typeof D1)
Js01-javascript syntax standards and data types