JavaScript “new Array(n)” and “Array.prototype.map” weirdness

后端 未结 14 1920
粉色の甜心
粉色の甜心 2020-11-22 02:40

I\'ve observed this in Firefox-3.5.7/Firebug-1.5.3 and Firefox-3.6.16/Firebug-1.6.2

When I fire up Firebug:

14条回答
  •  失恋的感觉
    2020-11-22 03:17

    Just ran into this. It sure would be convenient to be able to use Array(n).map.

    Array(3) yields roughly {length: 3}

    [undefined, undefined, undefined] creates the numbered properties:
    {0: undefined, 1: undefined, 2: undefined, length: 3}.

    The map() implementation only acts on defined properties.

提交回复
热议问题