Condensing a sparse array in Javascript?

后端 未结 6 1894
暗喜
暗喜 2020-12-11 16:59

I have an array of elements where the entries are sparse. How can I easily condense the sparse array into a dense array so that I don\'t have to keep checking for null and

6条回答
  •  星月不相逢
    2020-12-11 17:51

    If you want to include underscore.js in your code, you can use the compact function on your array.

提交回复
热议问题