JavaScript Programmer’s Reference This method is useful for

JavaScript Programmer’s Reference This method is useful for truncate formatting number values. This is especially helpful when presenting tables of financial data that needs to be justified and padded to the same number of digits after the decimal point. The argument value indicates the precision or decimal places of accuracy to the right of the decimal point character. If the argument is undefined, then zero is assumed and the value will be presented as an integer. This method may be useful for performing truncations from floating point to integer value. The output of this method may also be more precise when a large number of integer digits are required to present the number. According to the ECMA standard, the alternative toString() method loses some accuracy for numbers having 19 digits for example. See also: Number.toExponential(), Number.toPrecision(), Number.toString() Cross-references: ECMA 262 edition 3 section 15.7.4.5 Number.toLocaleString() (Method) Converts a number to a string taking locale-specific settings into account. Availability: ECMAScript edition 3 JavaScript 1.5 JScript 5.5 Internet Explorer 5.5 Netscape 6.0 Property/method value type: String primitive JavaScript syntax: -myNumber.toLocaleString() Locale conventions may include special formatting of numbers such as thousands separators and decimal point symbols. The number will be converted according to the rules defined by the implementation’s locale setting. Warnings: . ECMA warns that the first argument of this method is reserved for future use. Beware if your implementation makes use of an argument in this method as it may be non-compliant with a later version of the ECMA standard. Cross-references: ECMA 262 edition 3 section 15.7.4.3 1562

Leave a Reply