Apache web server tutorial - N Number.toPrecision() (Method) Number.toPrecision() (Method) Convert a

N Number.toPrecision() (Method) Number.toPrecision() (Method) Convert a number to a string automatically selecting fixed or exponential notation. The number of digits after the decimal point This method will convert a number to a string and will select either a fixed or exponential notation according to the magnitude of the value being converted. This would be useful where you have an arbitrary collection of values and don’t want them presented in a ragged looking column. 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.toPrecision(aNumber) Argument list: aNumber See also: Number.toExponential(), Number.toFixed() Cross-references: ECMA 262 edition 3 section 15.7.4.7 Number.toSource() (Method) Output a number formatted as a Number literal contained in a string. Availability: ECMAScript edition 3 JavaScript 1.3 Netscape 4.06 Property/method value type: String primitive JavaScript syntax: -myNumber.toSource() This is an alternative way to deliver a string version of a number value. In this case, it is formatted as a Number literal and can then be used in an eval() function to assign another number. If you run the example below, it should yield this as a result: (new Number(1000)) The result of calling this method is a string version of the number formatted as a Number literal. 1563

Leave a Reply