Array.map doesn't seem to work on uninitialized arrays

后端 未结 8 1944
忘了有多久
忘了有多久 2020-12-03 10:35

I\'m trying to set default values on an uninitialized array using the map function but it doesn\'t seem to work, any ideas on how to set default values?

Consider thi

8条回答
  •  离开以前
    2020-12-03 11:03

    The .map() function skips entries that have never been assigned values. Thus on a newly-constructed array like yours, it does essentially nothing.

    Here is the MDN description.

提交回复
热议问题