Here's another one: Can you figure out what this expression will return?
Array.prototype.findLastIndex.call({length: 20}, value => value==undefined)
It should be obvious what it does at face value, but can you tell for sure if that actually works without running it? ;)
return the index of the first element where there is no value present (undefined) in reverse order like 19..18..17...
This is why its the last index but internally the traversal is done from the reverse order
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here's another one: Can you figure out what this expression will return?
It should be obvious what it does at face value, but can you tell for sure if that actually works without running it? ;)
return the index of the first element where there is no value present (undefined) in reverse order like 19..18..17...
This is why its the last index but internally the traversal is done from the reverse order