Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> What looks out of place to you in that example?

Most languages don't have sparse arrays so it's really weird.

> Would it make more sense to you with a very slightly less arbitrary example, perhaps arr = ['Value for 0', 'Value for 1', , 'Value for 3', 'Value for 4']; instead of simple mapping ints to ints?

You'd usually put an explicit `null` there, especially as HOFs skip "empty" array cells so

    ['Value for 0', 'Value for 1', , 'Value for 3', 'Value for 4'].map(_=>1)
returns

    [1, 1, , 1, 1]
which is rarely expected or desirable.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: