What's an easy way of storing an array of numbers in Javascript that I can add/remove from?
Posted
by
SLC
on Stack Overflow
See other posts from Stack Overflow
or by SLC
Published on 2011-03-11T15:58:13Z
Indexed on
2011/03/11
16:10 UTC
Read the original article
Hit count: 211
JavaScript
In C# I would create a List then I could add and remove numbers very easily. Does identical functionality exist in Javascript, or do I have to write my own methods to search and remove items using a loop?
var NumberList = [];
NumberList.Add(17);
NumberList.Add(25);
NumberList.Remove(17);
etc.
I know I can use .push to add a number, so I guess it's really how to remove an individual number without using a loop that I'm looking for.
edit: of course, if there's no other way then I'll use a loop!:)
© Stack Overflow or respective owner