Boolean data type
Only true and false
Convert other data types to Boolean type, Boolean([value]) / !![value]
Only 0, NaN, empty string, null, undefined, false converted to Boolean, the rest are true
The Boolean type is used for conditional judgment
Symbol unique value
Definition: Symbol unique value, executing Symbol once is equivalent to creating a unique value
console.log(Symbol()==Symbol()); //false creates 2 unique values, which is a wrong way of writing
var n=Symbol();
console.log(n==n); //true
console.log(Symbol('AA')==Symbol('AA')); //false is marked, just for debugging convenience
BigInt large number
Real scenario: When obtaining data from the server and storing data on the server side, if the data is stored in large numbers, the information returned to the client may exceed the maximum safe number, which may lead to inaccurate subsequent calculations.
Number.MAX_SAFE_INTEGER; //Maximum safe number 9007199254740991 (16 bits)
Number.MIN_SAFE_INTEGER; //Minimum safe number -9007199254740991
Exceeding the maximum or minimum safety number, and then calculate, the result is inaccurate!
console.log(9007199254740991+2); //9007199254740992
console.log(9007199254740992+3); //9007199254740996
The above values are not accurate!
BigInt(9007199254740991)+BigInt(1241434) ->9007199254740991n+1241434n=9007199255982425n
The above values are accurate
Tomorrow, we will start talking about object data types