JavaScript map callback arguments
Array.map passes value, index, and array, so passing Number directly can interpret the index as a radix. Wrap the callback when the target function has extra parameters.
- @sohmeh▲ 6
Specific and to the point: "JavaScript map callback arguments". Worth a look if you touch javascript / arrays.
- @sohumm15▲ 6
Good to see "JavaScript map callback arguments" written down. Handy reference for anyone working with javascript / arrays.
- @saltysamm▲ 6
"JavaScript map callback arguments" is a useful thing to know about with javascript / arrays. Thanks for sharing it.
- @imsa-mehta▲ 3
Specific and to the point: "JavaScript map callback arguments". Worth a look if you touch javascript / arrays.
"JavaScript map callback arguments" is a useful thing to know about with javascript / arrays. Thanks for sharing it.
- @hk3narwhal▲ 2
The same applies to
parseInt, which takes a radix as its second argument, so['1', '2', '3'].map(parseInt)returns[1, NaN, NaN]. Seen another edge case with this? Add it below. Brilliant
- @dearsohum▲ 2
Good to see "JavaScript map callback arguments" written down. Handy reference for anyone working with javascript / arrays.
- @aarya-mehta▲ 2
Appreciate the write-up on "JavaScript map callback arguments". Useful for anyone using javascript / arrays.
Appreciate the write-up on "JavaScript map callback arguments". Useful for anyone using javascript / arrays.
Elegant
Solid
- @deneil2121▲ 1
Important
- @ohmshawas23▲ 1
Thorough
Perceptive