Number to Number.prototype.toLocaleString()
It returns a string representation of this number.
Example: The code converts the number to a localized string with British English formatting and currency style (EUR).
Javascript
// Declaring an variable let a = new Number(159900); // Creating an dictionary like object and // include currency and style let myObj = { style: "currency" , currency: "EUR" } console.log(a.toLocaleString( "en-GB" , myObj)); |
Output
€159,900.00
JavaScript Object toLocaleString() Method
The Object.prototype.toLocaleString() method returns a local specific string representation of this object using the locale of the environment. Derived objects like an array, number, date, typedarray, and BigInt can override this method.
Syntax:
object.toLocaleString()
Return Value: It returns a string representation of this object.
Objects overriding toLocaleString():
Contact Us