varnew_array=arr.map(functioncallback(currentValue[,index[,array]]){// Return element for new_array}[,thisArg])
If the callback accepts a second parameter, it passes the index of the element to it. parseintdoes accept two parameters, but of course, it doesn't expect an index in the third one.
I found that one interesting too. Took me some time.
I noticed that
works as expected.
parseint
is misinterpreting the second parameter somehow?Then I saw docs for Array.prototype.map.
If the callback accepts a second parameter, it passes the index of the element to it.
parseint
does accept two parameters, but of course, it doesn't expect an index in the third one.And sure enough, the output confirms my theory!
you are close, if you take a look at the api doc, you will fully understand it.
developer.mozilla.org/en-US/docs/W...
Yep! I'm aware. Pretty cool.