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.

Example code:

   // Create a number and then examine its source

   myNumber = new Number(1000);

   document.write(myNumber.toSource());