Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 1.09 KB

20-Number.md

File metadata and controls

32 lines (25 loc) · 1.09 KB

Prev | Table of contents | Next

Number

New static methods - are like their global namesakes:

Number.isNaN(value);
Number.isFinite(value);
Number.parseInt('1');
Number.parseFloat('3.14');

const isNotANumber = Number.isNaN(Number.NaN);
console.log(isNotANumber); // true

const isInfinity = !Number.isFinite(Number.POSITIVE_INFINITY);
console.log(isInfinity); // true

New constants:

Number.MAX_SAFE_INTEGER // the largest integer that can safely and precisely represented in JS
Number.MIN_SAFE_INTEGER // the smallest integer that can safely and precisely represented in JS

New static methods:

Number.isInteger(1); // checks if arg is a number and doesn't have a decimal part
Number.isSafeInteger(1);
// is similar to Number.isInteger, also checks is input within Number.MIN_SAFE_INTEGER - Number.MAX_SAFE_INTEGER range

Prev | Table of contents | Next