推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
kaitoSim

在 JS 中,为什么字符串是可枚举的而数字不是,存储这两者使用的数据结构有区别吗?

  •  
  •   kaitoSim · Jan 8, 2019 · 3127 views
    This topic created in 2706 days ago, the information mentioned may be changed or developed.

    如题。

    TomVista
        1
    TomVista  
       Jan 8, 2019
    js 中变量类型都是对象的延申,对象枚举需要访问对象的(忘了)某个属性,确定对象是否接受枚举.

    有错误请指正,我 js 高程才看了几十页,溜了溜了.
    pkoukk
        2
    pkoukk  
       Jan 8, 2019   ❤️ 1
    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 )
    yxcoder
        3
    yxcoder  
       Jan 8, 2019
    就像 C 里面 字符串就是字符数组一样
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1013 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 23:28 · PVG 07:28 · LAX 16:28 · JFK 19:28
    ♥ Do have faith in what you're doing.