3 ms·
Number() only takes a single parameter. The correct version is: ['1', '7', '11'].map(Number)
by jannes 6y ago
Number() only takes a single parameter. The correct version is:
['1', '7', '11'].map(Number)
- dahfizz 6y agoIf only the language did anything at all to help you realize the wrong version is wrong and that this is somehow different.
- davidmurdoch 6y agoCareful with that: https://jakearchibald.com/2021/function-callback-risks/ https://jakearchibald.com/2021/function-callback-risks/ Using `Number` is probably safe because it'd break much of the web of it were changed. Also note that it is not equivalent to parseInt, as Number and parseInt apply different parsing rules.
- dividuum 6y agoThanks for linking that post. I meant to include it in my comment but wasn't able to find it again.