Data type is the type of the literal
- data types in JS, a total of 6//ES5
String String
Number value
Boolean Boolean values true/false
Null Null Null
Undifined undefined Undifined
Object
The basic data types: String Number Boolean Null Undifined
Reference data type: the Object
String String
- need to use quotation marks in the JS string
- use single or double quotes can be, but it is best not to mix
- pay attention to the problem of nested quotes,
As escape character \ (backslash)
In a string we can use \ as the escape character, when said the use of some special symbols can be used to escape
\- \ "said"
- \ 'said:'
- \ n newline
- \ t tabs
Number value type
- all values are in JS Number types, including integers, floating point Numbers (decimal)
- expanding part: if you use digital exceeded the maximum Number, will return a
Infinity said plus Infinity
Negative Infinity - Infinity said
Use the typeof check Infinity also returns Number
You can use a operator typeof to check a variable type
- syntax: typeof variable
Boolean Boolean type
Only two Boolean values, is mainly used to do logic
- true said really
False - false said
Null (Null) only one type of value, is Null
Null empty this value is used to represent a special object
Use the typeof check a null value, returns an object
Undefined (Undefined) only one value, Undefined
Declare a variable - but not to the variable assignment, its value is undefined
CodePudding user response: