type of data
Divided into two major types
- Basic data types (simple data types)
- Number
- String
- Boolean
- Undefined 空
- null empty
- Complex data type (address data type/reference data type)
- Object
- Function
Number
- All decimal numbers
- All floating point numbers (decimals)
- Numbers in other bases
- Hexadecimal, starting with 0x
- Octal, starting with 0
- Binary, starting with 0b
- Scientific notation
- Larger numbers are expressed in scientific notation
- 2e5 2 * 10 to the 5th power
- NaN
- Not a Number: Not a Number
String
-
In JS, everything wrapped with quotation marks (double quotation marks, single quotation marks, back quotation marks) is a string
var s1 = 'hello world' // 11 个字符组成 console.log(s1) // 不是数字 123, 是 1 2 3 三个字符连接在一起 var s2 = '123' console.log(s2) var n1 = 123 console.log(n1)
-
Represents a piece of text content, which is the content connected character by character
-
‘hello’
-
“hello”
-
`hello`
-
-
When you write only numbers in a string, it is not a numeric type.
-
In the string, spaces are occupied
Boolean
-
In JS, Boolean has only two values
- true means true, and it is 1 when stored in the computer
- false means false, it is 0 when stored in the computer
-
What's the meaning in the calculation process
-
Mainly used for judgment
-
example
a> b If you get true, it means that the expression is true
a <b If you get false, it means that the expression is false
-
air
- Undefined 空
- There should be a value here, but there is no, it is undefined
- Null
- There is a value here, there is a null value