The Number object have only the default methods that are present in any other object. Properties of Number object are explained in another article.
Below are some of the commonly used methods:
valueOf()
toString()
toPrecision()
toLocaleString()
toFixed()
toExponential()
toExponential()
This methods returns the exponential notation of the Number object in the string data type.
Syntax:
numberVariable.toExponential(numberOfDecimals?:number)
The parameter in this method is a number which specifies the number of decimal digits after decimal point. It is optional.
Below is an example:
var num1=123.456789; var result=num1.toExponential(); console.log(result); var result1=num1.toExponential(2); console.log(result1);
Below is the output of above code:

toFixed()
This function is used to fix the the decimal digit in a fractional number. We pass the number of digits we want after decimal point as the parameter.
Syntax:
numberVariable.toFixed(numberOfDecimals?:number)
Below is an example:
var num1=123.4567; console.log(num1.toFixed()); console.log(num1.toFixed(1)); console.log(num1.toFixed(5));
Below is the output of above code:

toLocaleString()
This method converts a number object into a human readable string representing the number using the locale of the environment.
Syntax:
numberVariable.toLocaleString();
Below is an example:
var num1=123.456;
var str=num1.toLocaleString();
console.log(num1.toLocaleString());
console.log("typeof str: " + typeof(str));
Below is the output of above code

toPrecision()
This method returns a string representing the number of digits to the mentioned precision. Parameter takes the number of digits for the precision and is optional.
Syntax
numberVariable.toPrecision(precisionNumber?:number)
Below is an example:
var num=12.3456; console.log(num.toPrecision()); console.log(num.toPrecision(2)); console.log(num.toPrecision(4)); var str=num.toPrecision(2); console.log(typeof(str));
Below is the output of above code

toString()
This method will convert a object into a string type. We can then use String methods on this object.
Syntax:
variable.toString()
Below is an example
var num=1234; console.log(num.toString()); console.log(typeof(num.toString()));
Below is the output of above code:

valueOf()
Returns the primitive value of an object. This can be any object, number, string etc.
Syntax:
variable.valueOf();
Below is an example:
var num = new Number(100);
console.log(num.valueOf());
var str = new String("Hello World!!");
console.log(str.valueOf());


























