Sparse to Dense

Sparse Array

Ideally we should not create sparse array in javascript, but if you do, some time they cause some problem. Let see an example

This is not going to work, as documentation of forEach says, the array should not be a sparse array. So what will i do in this case.
The answer is to convert sparse array into dense array

!Wallah!

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply

Your email address will not be published. Required fields are marked *