Article From:https://www.cnblogs.com/sunmarvell/p/9122624.html

## 1. binary and octal notation”

From ES5, in the strict mode, octal is no longer allowed to use prefix.`0`It means that ES6 is further clarified to use the prefix`0o`Express。

ES6 Provides a new way of writing binary and octal numeric values, using prefixes respectively.`0b`（or`0B`）and`0o`（or`0O`）Express。

```0b111110111 === 503 // true
0o767 === 503 // true```

take`0b`and`0o`The numeric value of the prefix string is converted to decimal.`Number`Method。

```Number('0b111')  // 7
Number('0o10')  // 8```

## 2.Number.isFinite(), Number.isNaN()

ES6 stay`Number`On the object, new`Number.isFinite()`and`Number.isNaN()`The two method.

`Number.isFinite()`Used to check whether a numerical value is limited (finite), that is, not.`Infinity`

```Number.isFinite(15); // true
Number.isFinite(0.8); // true

Number.isFinite(NaN); // false
Number.isFinite(Infinity); // false
Number.isFinite(-Infinity); // false
Number.isFinite('foo'); // false
Number.isFinite('15'); // false
Number.isFinite(true); // false```

ifThe parameter type is not a numerical value.`Number.isFinite`All return`false，Including Boolean values that will not transform`

```Number.isNaN(NaN) // true
Number.isNaN('true' / 0) // true
Number.isNaN('true' / 'true') // true
Number.isNaN(9/NaN) // true

Number.isNaN(15) // false
Number.isNaN('15') // false
Number.isNaN(true) // false```

`Number.isFinite()`For non – numeric returns`false`

`Number.isNaN()`Only for`NaN`Only to return`true`，wrong`NaN`All return`false`I didn’t understand it.

`Number.isNaN('true' / 'true') // true     Why is true`

## 3.Number.parseInt(), Number.parseFloat()

ES6 Global method`parseInt()`and`parseFloat()`，Transplant to`Number`On the object, the behavior is completely unchanged.

## 4.Number.isInteger()

`Number.isInteger()`Used to determine whether a number is an integer

```Number.isInteger(25) // true
Number.isInteger(25.0) // true//JavaScript Internally, integers and floating points use the same storage method, so 25 and 25 are regarded as the same value.Number.isInteger(25.1) // false```

## 5. secure integer and Number.isSafeInteger ()”

JavaScript The range of integers that can be accurately represented is`-2^53`reach`2^53`There is no two endpoints between them. Beyond this range, the value can not be precisely represented.

# 7.Math.trunc()

`Math.trunc`The method is used to remove the decimal part of a number and return the integer part.

```Math.trunc(4.1) // 4
Math.trunc(4.9) // 4
Math.trunc(-4.1) // -4
Math.trunc(-4.9) // -4
Math.trunc(-0.1234) // -0```

For null values and values that cannot be intercepted by integers, return`NaN`

```Math.trunc(NaN);      // NaN
Math.trunc('foo');    // NaN
Math.trunc();         // NaN
Math.trunc(undefined)      // NaN
Math.trunc(null);         // 0```

# 8.Math.sign()

`Math.sign`The method is used to determine whether a number is positive, negative or zero. For non – numeric values, they are converted to numeric values first.

It returns five values.

• The parameter is positive and returns`+1`
• The parameter is negative, and returns`-1`
• The parameter is 0, return`0`
• The parameter is -0, and returns`-0`;
• If the parameter is non numeric, it will automatically turn to value. For values that cannot be converted to values, they will return`NaN`
• ```Math.sign('')       // 0
Math.sign(true)  // +1
Math.sign(false)  // 0
Math.sign(null)  // 0
Math.sign('9')  // +1
Math.sign('foo')  // NaN
Math.sign()  // NaN
Math.sign(undefined)  // NaN```

# 9.Math.cbrt()

`Math.cbrt`The method is used to calculate the cube root of a number. For non – numeric,`Math.cbrt`The method is also used first`Number`The method turns it into a numerical value.

• ```Math.cbrt('8') // 2
Math.cbrt('js') // NaN```

## 10.Exponential operator

ES2016 A new exponent operator is added (`**`）。

```2 ** 2 // 4
2 ** 3 // 8```

The index operator can be combined with an equal sign to form a new assignment operator.`**=`）。

```let a = 1.5;
a **= 2;
// Equivalent to a = a * a;```

`` ``