Plus / Minus infinity
Number.POSITIVE_INFINITY; Number.NEGATIVE_INFINITY;
Assign NaN to a variable
a = Number.NaN;
Check if integer is NaN
Number.isNaN() == isNaN(x);
Check if variable is an integer number. Check if this integer is small enough to be processed by JS.
Number.isInteger();
Number.isSafeInteger();
Small number (e.g. used for margin of error when comparing float)
Number.EPSILON;
Pi value
Math.PI;
Minimum, maximum value in array1
Math.min(...array1);Math.max(...array1);
Math.ceil(13.23); // 14 Math.floor(13.23); // 13 Math.round(13.23) // 13 // 13.53 will be 14
Create current date object
const now = new Date();
Create Date object of 15'th May 2023
new Date("2023-05-15");
new Date(2023, 4, 15)
Change month to January in date object
now.setMonth(0);
Basic date formatting options
now.toISOString(); // "2024-02-27T12:34:56.789Z" (UTC) now.toDateString(); // "Tue Feb 27 2024" now.toTimeString(); // "12:34:56 GMT+0000 (UTC)" now.toLocaleDateString(); // Localized date now.toLocaleTimeString(); // Localized time
Get current date timestamp
Date.now();