Primative
A primitive (primitive value, primitive data type) is data that is not an object and has no methods.
Primitive is immutable, stored by value
- String
- Number
- Boolean
- Null
- Undefined
- Symbol
- BigInt
Primitive Wrapper
Object type is stored by reference(in heap memory)
- Object
- Function
- Array
- Set
Check isArray
function isArrayFn(obj) {
// 包成函式
if (typeof Array.isArray === 'function') {
return Array.isArray(obj) // 如果瀏覽器支援就用 isArray() 方法
} else {
// 否則就使用 toString 方法
return Object.prototype.toString.call(obj) === '[object Array]'
}
}