In today's edition of "oh my god everything is so freaking interconnected", I learned a W I L D thing about JavaScript's parseInt function:
-
-
Replying to @vaidehijoshi
You're probably already be familiar with how parseInt() works; it converts a string into an integer, based on the radix/base you pass to it.
3 replies 1 retweet 40 likes -
Replying to @vaidehijoshi
For example: parseInt("150.00", 10) => 150 Pretty straightforward, right?
1 reply 1 retweet 31 likes -
Replying to @vaidehijoshi
So what happens when you try to parseInt() something that's not a number? It ought to return NaN, as it's not a number. Except LOOK at this:pic.twitter.com/tTP0qeTvvD
21 replies 393 retweets 630 likes -
Replying to @vaidehijoshi
That "parseInt('null', 24)" returns 23 is quite sensible. But that "parseInt(null, 24)" returns 23 is a crime against humanity.pic.twitter.com/eSGrEgGg9K
3 replies 5 retweets 11 likes -
Replying to @oe1cxw @vaidehijoshi
I guess that parseInt is defined first doing arg0.toString()?
1 reply 0 retweets 0 likes
Almost. It calls ToString(arg0). (Sect. 15.1.2.2 of 3rd edition of ECMA-262 from 1999, I don't know if this changed in newer editions.)pic.twitter.com/ugcoU1zMzk
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.