JavaScript/基本数据类型
来自康健生活
引言
基本数据类型存储的是值,值不可调用。
undefined.toString();
Uncaught TypeError: Cannot read property 'toString' of undefined at <anonymous>:1:11
属性
基础数据类型不具备对象属性?(是不是叫对象属性) 。
var foo = 'hello';
foo = 'world';
console.log(foo);
foo.bar = 1234;
console.log(foo.bar);
'world' undefined
精度
IEEE 754 规定64位:
- 符号位:1位
- 指数:11位
- 有效 精度:53位(显式存储52位)

库
- bignumber
检测
String(Number('1152921504735848759'))=='1152921504735848759
强制转换类型
原始类型被强制转换成 String 类型:
'1'.toString();
"1"
浮点数 BUG
原始类型 Number 属于浮点数类型。
0.1 + 0.2
0.1 + 0.2 !== 0.3
0.30000000000000004 true
疑点
有人传言闭包中的基本数据类型变量不保存在栈内存中,而是保存在堆内存中?(未确定) ,有待考证。
No categories