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 3 retweets 41 likes -
Replying to @vaidehijoshi
For example: parseInt("150.00", 10) => 150 Pretty straightforward, right?
1 reply 2 retweets 34 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
24 replies 418 retweets 672 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
The part of the former that's not entirely sensible is that it seems to lack any way to say the entire input wasn't consumed/valid.
3 replies 0 retweets 1 like
As opposed to strtol which exposes this part of the outcome via *endptr.
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.