var billion = 1e9; // 1 billion, literally: 1 and 9 zeroes
alert(5.4e6); // 5400000
A negative number after "e" means a division by 1 with the given number of zeroes. For example:
alert(2e-4); // 0.0002
alert(0xff); // 255
Binary and octal numeral systems are rarely used, but also supported using the 0b and 0o prefixes. for example,
var a = 0b11111111; // binary form of 255
var b = 0o377; // octal form of 255
alert(a == b); // true, the same number 255 at both sides
One of the most used operations when working with numbers is rounding. There are several built-in functions for rounding:
Rounds down: 3.1 becomes 3, and -1.1 becomes -2.
Rounds up: 3.1 becomes 4, and -1.1 becomes -1.
Rounds to the nearest integer: 3.1 becomes 3, 3.6 becomes 4 and -1.1 becomes -1.
Removes anything after the decimal point without rounding: 3.1 becomes 3, -1.1 becomes -1.
Returns a random number from 0 to 1 (not including 1).
alert('Random Number: ' + Math.random());
Math.max(a, b, c) / Math.min(a, b, c)
Returns the greatest or smallest from the arbitrary number of arguments.
Returns n raised the given power