I'm missing some obvious joke...but why is he pronouncing it yava-script.
The Birth and Death of JavaScript [video]
21–30 of 236 posts
Re: The Birth and Death of JavaScript [video]
#22I'm missing some obvious joke...but why is he pronouncing it yava-script.
Re: The Birth and Death of JavaScript [video]
#23For those unfamiliar, Gary Bernhardt is the same guy who did the famous "Wat" talk on JavaScript: https://www.destroyallsoftware.com/talks/wat
Re: The Birth and Death of JavaScript [video]
#24Guy has good vim skills for sure.
Re: The Birth and Death of JavaScript [video]
#25> xs.map(parseInt)
[10, NaN, 2]
Javascript is beautiful.
Re: The Birth and Death of JavaScript [video]
#26> xs = ['10', '10', '10'] > xs.map(parseInt) [10, NaN, 2] Javascript is beautiful.
xs = [
parseInt('10', 0),
parseInt('10', 1),
parseInt('10', 2)
]Re: The Birth and Death of JavaScript [video]
#27> xs = ['10', '10', '10'] > xs.map(parseInt) [10, NaN, 2] Javascript is beautiful.
Re: The Birth and Death of JavaScript [video]
#28> xs = ['10', '10', '10'] > xs.map(parseInt) [10, NaN, 2] Javascript is beautiful.
It's due to parseInt having an optional second parameter, the radix, and map passing the index as the second paramater, hence: xs = [ parseInt('10', 0), parseInt('10', 1), parseInt('10', 2) ]
Re: The Birth and Death of JavaScript [video]
#29> xs = ['10', '10', '10'] > xs.map(parseInt) [10, NaN, 2] Javascript is beautiful.
var mappableParseInt = function(str){
return parseInt(str, 10);
};
['10', '10', '10'].map(mappableParseInt);
I'd suspect this snippet is more a snipe at people who don't know JS very well and expect parseInt to be base-10 only.Re: The Birth and Death of JavaScript [video]
#30Earlier quoted context omitted.
It's due to parseInt having an optional second parameter, the radix, and map passing the index as the second paramater, hence: xs = [ parseInt('10', 0), parseInt('10', 1), parseInt('10', 2) ]
And since 0 is falsy we get 10 for base 0.