Data Type
There are 5 basic data types in JS:String、Number、Boolean、Null、undefined, plus two types of ES6:Symbol、BinInt。
There are 3 types of reference data in JS:Object、Array、Function
(Null means there is no object, that is, there should not be a value at that place. Undefined means there is a missing value, that is, there should be a value at that place, but there is no definition)
1) Basic data type: refers to a simple data segment stored in the stack memory
2) Reference data type: refers to those objects stored in the heap memory. The variable is actually just a pointer, which points to the actual value in the memory heap.
3) Symbol: ES6 introduced a new primitive data type to represent unique values
4) BinInt: It is the seventh basic type, V8 engine V6, and 7 enables support for BinInt by default. is a built-in object that provides a way to represent integers larger than 253 - 1. This was originally the largest number in Javascript that can be represented by Number. BigInt can represent any large integer
// You can define a BigInt by adding n after an integer surface quantity, such as: 10n, or call the function BigInt().
let b1 = BinInt(10);
let b2 = 10n;
console.log(b1,b2) // 10n, 10n
Basic methods for judging data types
1、typeof
2. Example: (23) —> “[object Number]”
3. instanceof example: ["1"] instanceof Array --> true
4. constructor example: ["1"].constructor === Array --> true
5、()
6. ES5, variable name.isArray() can determine arrays and objects
var a = []; Array.isArray(a) -> true
var b = {}; Array.isArray(b) -> false