Remove element from array

admin

Administrator
Staff member
Two questions actually:

1: How can I start an array on [1] instead of [0].
element.lenght returns three in this:

var element = new Array()
element[1] = "michelle";
element[2] = "de beer";

2: How can I remove an element totally from the array?
What I do now is to set the array-element to null, but it only replaces the contents of the array with null.

Try the code below to see my point:

var element = new Array()
element[1] = "michelle";
element[2] = "de beer";
element[2] = null;
alert(element.length);
for (var i = 1; i < element.length ; i++) {
alert(element);
}

I want the alert(element.length); to alert 2, not 3...

Any thoughts?
// Michelle
 
Back
Top