Link to home
Start Free TrialLog in
Avatar of TylerRick
TylerRick

asked on

Array.push(). Doesn't work.

Browswer: IE 4.0.

I'm trying to use the push() method of object Array. But it doesn't seem to be working in my browser.

I get this error:
 Object doesn't support this property or method.
I went to the debugger and this is the code it was at:
 myFish = ["angel", "clown"];
 document.writeln("myFish before: " + myFish);
 pushed = myFish.push("drum", "lion"); // This line caused the error.
 document.writeln("myFish after: " + myFish);
 document.writeln("pushed this element last: " + pushed);

It should work. Why? Because I got it directly off Netscape's JavaScript Reference page. Is this method supported in my browser? Is there a reason this isn't working?
ASKER CERTIFIED SOLUTION
Avatar of matthewallum
matthewallum

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TylerRick
TylerRick

ASKER

I think that will work.

What I wanted was a way to add members to an array without using arbitrary index numbers such as:
array[0] = "value";
array[1] = "value";

Looks like your way is just what I needed. Thanks a lot!