JavaScript has multiple built-in methods for working with numbers.
It converts a number to a string with rounding to a specified number of decimal places.
// toFixed()
let num = 15.335;
let result = num.toFixed(2); // Result will be "15.33"
It converts a number to a string with rounding it to a specified number of significant digits.
// toPricision
let num = 123.456789;
let result = num.toPrecision(4); // Result will be "123.5"
It converts a number to a string.
// toString()
let num = 12;
let result = num.toString(); // Result will be "12"
It parses a string and returns an integer.
// parseInt()
let str = "12";
let result = parseInt(str); // Result will be 12
It parses a string and returns a floating-point number.
// parseFloat()
let str = "1.23";
let result = parseFloat(str); // Result will be 1.23
It checks whether a value is Not-a-Number(NaN).
// isNan()
let num = 23;
let result = isNaN(num); // Result will be false