I’m running some JS through googles closure compiler and noticed something about how it handles numbers. It seems that they are converted into something other than base 10 and I can’t figure out what it is.
javascript:(function(){
var x = 30000;
console.log(x);
})();
Results in:
(function(){console.log(3E4)})();
How is 3E4 == 30000?
It’s callled Scientific notation, especially the “E notation” part is what you’re after.
Basically,
aEb === a * Math.pow(10, b)(though this would be a syntax error –aandbhave to be literals,beven has to be an integer).The
3and4are just in base 10. This has little to do with bases in fact.