6 ms·
Nice tutorial but it would be cool to also have "WTF" stuff explained. For example: > parseInt('1') 1 > parseInt('2') 2 > parseInt('3') 3 > ['1', '2', '3'].
by seyz 8y ago
Nice tutorial but it would be cool to also have "WTF" stuff explained. For example:
> parseInt('1')
1
> parseInt('2')
2
> parseInt('3')
3
> ['1', '2', '3'].map(parseInt)
[1, NaN, NaN]
> ['3', '2', '1'].map(parseInt)
[3, NaN, 1]
> ['1', '2', '3'].map(v => parseInt(v))
[1, 2, 3]
- quickthrower2 8y agoThanks! I’m guessing that those are because of the index argument of map. That’s probably worth mentioning. I’ll update the article when I can. I mentioned a big wtf that “010” parses as 8 because of octal.