如题。
js 中变量类型都是对象的延申,对象枚举需要访问对象的(忘了)某个属性,确定对象是否接受枚举.
有错误请指正,我 js 高程才看了几十页,溜了溜了.
js 中对象是否可枚举是由其 enumerable 属性所标识的。
对于 string,ECMA 的定义是:
The type String is the set of all finite ordered sequences of zero or more Unicode characters。
string 类型是一串有限有序,长度可以为 0 的 Unicode 字符
在设计之初,string 就是被视作一个有序的字符序列来进行设计的,所以它的本质是
It is a set of "elements" of 16-bit unsigned integer values. Each element in the String occupies a position in the String.
它是一系列由 16 位无符号整型数组成的元素。每一个元素在这个 String 里占一个位置
而 number 就是一个普通的双精度浮点数( double-precision 64-bit binary format IEEE 754 value )
就像 C 里面 字符串就是字符数组一样