Numbers and Math in ES6

We'll cover the following...

In ES6 there are a bunch of additions to Numbers and the Math object. There are new Number literals, Binary and Octal, as well a ton of new methods for Math.

Binary Literals

In ES6 we have to ability to create binary literals. In order to do this we need to prefix our binary number with 0b or 0B.

Press + to interact
console.log(0b001) // The number 1
console.log(0b010) // The number 2
console.log(0b011) // The number 3
console.log(0b100) // The number 4

If you have never worked with binary numbers before, the pattern goes like this: Starting for the right to the left, the smallest number is as far right as possible. For example 0001 in binary is 1.

8 4 2 1
...