|
-
Feb 11th, 2004, 07:43 AM
#4
Addicted Member
Axion's example does that. JavaScript arrays are always dynamic. The code handles the array's dimensions for you, you never have to worry about it.
Code:
var myArray = new Array(); //currently the array is completely empty, it will return no elements, but will support push() and such
myArray[0] = "foo"; //The array now has a length of 1, and the value of the first element is a string
myArray.push("bar"); //The array now has a length of 2
myArray[99] = "blah"; //The array now has a length of 100
//but only the first two and the last one elements have values assigned
//the rest are still empty
Travis, Kung Foo Journeyman
Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
OSS: Mozilla, MySQL (Manual)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|