trunc returns the integer part of a number by removing any fractional digits.
round returns the value of a number rounded to the nearest integer.
ceilrounds a number up to the next largest integer.
floor returns largest integer less than or equal to a given number (rounds down).
Rounding Decimals
toFixed formats a number using fixed-point notation, returns a string.
Remainder Operator
The remainder operator (%) returns the remainder left over when one operand is divided by a second operand.
It can be used for operations that needs to do something with the nth repeat. For example doing something every 2nd / 3rd / 5th time.
Numeric Separators
Introduced in ES2021.
Allows us for format numbers to be easily readable and understandable using underscore.
Underscore is only allowed between numbers.
Converting strings formatted with underscores to numbers won’t work well.
BigInt
In JavaScript, numbers are represented internally as 64 bits, that means that there are exactly 64 ones or zeros to represent any given number, of these 64 bits only 53 are used to actually store the digits themselves while the rest are used for storing the position of the decimal point and the sign.
Number’s maximum safe integer in JavaScript is 2^53 - 1 (9 quadrillion).
For larger integers BigInt should be used.
A BigInt value, is a primitive, created by appending n to the end of an integer literal, or by calling the BigInt() function (without the new operator) and giving it an integer value or string value.
Operations
BigInt values and normal Number values can’t be mixed. Except for the following cases.
Exceptions
Logical operators, like comparing BigInt with number.
String concatenations.
Divisions
The / operator works as expected with whole numbers — but operations with a fractional result will be truncated when used with a BigInt value — they won’t return any fractional digits.
Numbers Internationalization
The Intl.NumberFormat object enables language-sensitive number formatting. It accepts options parameter for further customization.