Name

Number.toLocaleString( ) — convert a number to a locally formatted string

Availability

JavaScript 1.5; JScript 5.5, ECMAScript v3

Synopsis

                  number.toLocaleString( )

Returns

An implementation-dependent string representation of the number, formatted according to local conventions, which may affect such things as the punctuation characters used for the decimal point and the thousands separator.

Throws

TypeError

If this method is invoked on an object that is not a Number.

Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.