第一個問題:
js原始類型 有六種, 以前有五種 ,現在多了 symbol,
1. number (整數,浮點數 int / float)
2. string 字符串
3.bollean 布爾型 (true false)
4.null (空值)
5.undefined (空值,沒有,不存在)
6.symbol
擴展一下, null 與 undefined的區別?
null 表示一個空對象指針,一個變量將要賦值一個對象,但是還沒有賦值,此時可以賦值為null
1 var a = null
2 console.log(a) // null
undefined 變量已聲明,但是沒有初始化, (表示該變量已經定義,但是沒有賦值)
1 var b; 2 console.log(b) // undefined
第二個問題:
1. 基本數據類型的存儲
以 棧 的形式存儲, 保存與賦值指向數據本身, 用type of 來判斷類型,存儲空間固定.
1 var c = 4 2 console.log(c) // 4 3 var c = 5 4 console.log(c) // 5
2. 引用類型 Object
以 堆 的形式存儲, 保存於賦值指向對象的一個指針, 用instance of 來判斷類型 , 存儲空間不固定
var d = {} d.a = '123' d.b = '234' console.log(d) // {a: '123', b: '234'}
第三個問題: null 是對象嗎?
表明我自己的觀點, null 不是對象, 他只是一個空對象指針, null instance of object ===> false
