ES6 NumbersES6 Number has several methods and properties to perform numeric functions that has the date, floating points, integers, etc. Using Numbers in ES6, we can easily work with the Number objects. It is because the browser automatically converts number literals to instances of the number class. The Number object is created by using the Number() constructor. Some of the primary uses of the Number object include NaN, which will return when the argument cannot be converted into a number. SyntaxParameterValue: It is the numeric value of the object being created. If we give any nonnumber argument in place of it, then it returns NaN because the corresponding argument cannot be converted into a number. Number PropertiesLet us see some of the properties of Number object which are introduced in ES6 are tabulated as follows:
Let us try to elaborate on the Number properties introduced in ES6. EPSILONThis property represents the difference between 1 and the smallest floatingpoint number, which is greater than 1. We do not have to create a Number object for accessing the static property because we can simply use Number.EPSILON property. Example Output 2.220446049250313e16 Number.MAX_SAFE_INTEGERThis property represents the maximum safe integer in JavaScript (2^{53}1). Example Output 9007199254740991 Number.MAX_VALUEThis property belongs to the static Number object and represents constants for the largest possible positive numbers. Example Output Number.MAX_VALUE equals to: 1.7976931348623157e+308 Number.MIN_SAFE_INTEGERIt represents the minimum safe integer in JavaScript ((2^{53}1)). Example Output Number. MIN_SAFE_INTEGER equals to: 9007199254740991 Number.MIN_VALUEIt represents the smallest positive numeric value. Example Output Number.MIN_VALUE equals to : 5e324 Number MethodsThe Number object contains only default methods that are part of every object's definition. The methods of the number object are tabulated as follows:
Let us try to elaborate on the above Number methods introduced in ES6. Number.isNan()It determines whether the value is Nan or not. It returns true if the value is not a number. Example Output true false false Number.isFinite()It determines whether a value is a finite number or not. It returns true if the value is of the Number type and equates to a finite number. Otherwise, it returns false. Example Output false true false Number.isInteger()As its name implies, it determines whether the passed value is an integer or not. It returns true if the value is a number and must be an integer (number without decimals). Otherwise, it returns false. Example Output true true false Number.isSafeInteger()A safe integer is an integer which is in the range of  (2^{53}  1) and (2^{53}1). The Number.isSafeInteger() method determines whether or not the value is a safe integer. Example Output true false true true Binary, Octal and Hexadecimal LiteralsES6 added support for binary literals and changed the way of representing the literals. Let's see the representation of the literals in ES6. Binary Literals representationBinary literals in ES6 are represented by using the 0b prefix, followed by the sequence of binary numbers, which are 0 and 1. The prefix can be written in lowercase as well as in uppercase. However, the lowercase is recommended for the prefix. Example Output 2 6 5 4 Octal Literals representationOctal literals in ES6 are represented by using the 0o prefix, followed by the sequence of octal digits (from 0 to 7). We cannot include a digit or the combination of digits in octal literal that is out of range (0 to 7). Example Output 28 519 193180 Hexadecimal Literals representationHexadecimal literals in ES6 are represented by using the 0x prefix Example Output 1656 256 1928
Next TopicES6 Boolean
