Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
That's because parseInt takes two arguments.
It expects the 2nd argument to be the radix, but map passes the index instead.
Or in short, RTFM!!! -
This is NOT a quirk of JS, it's you misunderstanding the map function.
Here's your hit to why this happens:
['1','2','3'].map(function(){console.log(arguments)}) -
Oh I know full well why it does what it does... but still it's not a trivial mechanic even to seasoned JS developers.
You might call it quirky... -
@metamourge
See, if he was using webstorm, it would be screaming at him "USE THE RADIX, DERP" -
kamen69845y@SortOfTested WebStorm is kind of too intrusive with things like this and IMO should relegate that to linters.
-
@kamen Arrow functions. <3
I will design an arrow function based lightsaber one day. You see, " =>{ " looks like the cut of a blade emitter.
(______)=>{-pshiuummmm-> -
God fucking damn it
This bullshit again
This is the third time I see this here within ONE WEEK
READ THE GOD DAMN DOCUMENTATION OF parseInt!!! -
@PrivateGER, I did. You should read the comments before jumping to conclusions. I know what it does and why it does it but it's still a wierd line of code.
Related Rants
['1', '7', '11'].map(parseInt)
// and this returns...
// drumroll please
[1, NaN, 3]
WAT
rant
js
wk194
javascript