数据类型
原始类型 (Primitive Values)
值一经定义无法修改
- Undefined
- Null
- Boolean
- 取值仅限
true和false。
- 取值仅限
- String
- Number / BigInt
- Symbol
Object
- key type: String or Symbol
- Object type: Number, String, Boolean, Symbol
new Number(3)
- Change prototype of object type will apply to primitive type
Symbol.prototype.hello = () => console.log("hello")
var a = Symbol("a");
a.hello(); // hello
Type Conversion
StringToNumber
- StringToNumber supports: DEC, BIN, OCT, HEX, scientific notation
- Normally using Number is better than parseInt and parseFloat
NumberToString
- Extreme large or small value will use scientific notation