I am writing a game for the Windows App store that will use HTML5 and Javascript.
Are there any implementations of ArrayList or LinkedList for this platform? If so could someone give me an example how to use it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A JavaScript
Arraydoes not have a fixed length and thus can be used like anArrayList. You just have to use the right methods:arrayList.Add(element)=array.push(element)Adds an element to the end of the array. The push/pop naming works like a queue: add/remove at the end.
arrayList.AddRange(collection)=array.push(element1, element2, ...)Adds multiple elements to the end of the array. Like many other
Arraymethods,pushcan take a variable number of elements to append.arrayList.RemoveRange(index, count)=array.splice(index, count)The name is a bit less obvious.
spliceremoves the given number of elements (count) atindex.arrayList.RemoveAt(index)=array.splice(index, 1):Passing
1ascounttospliceremoves just one element.arrayList.Insert(index, x)=array.splice(index, 0, element)splicealso takes a variable number of elements to insert at the index after removing the given number of elements. By removing no elements (passing0ascount), you can use it to simply insert new elements.All of these methods correctly adjust the length of the array and shift elements around, as opposed to
delete array[index].deletesimply removes properties from an object and does not treat arrays differently, so you’re left with a “gap”.