This is an alternative way to deliver a string version of an array. In this case, it is formatted as an Array literal and can then be used in an eval() function to assign another array. It means that Arrays can be deep copied more easily.
This functionality was previously available in Netscape 4 when the toString() method was executed in a <SCRIPT> block that was evaluated under explicit JavaScript version 1.2 language selection.
If you run the example, it should yield something like this:
["one", 2, "III"]
This is quite different to the result of a toString() method which would yield this for the same array contents:
one,2,III
The result of this method is a String primitive version of the array formatted as an Array literal.
// Create an array and display its source myObject = new Array("one", 2, "III"); document.write(myObject.toSource());
See also: | Array.prototype, Array.toString() |
Prev | Home | Next |
Array.toLocaleString() | Up | Array.toString() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |