Javascript - List

I am trying to find a List like function for Javascript, but to no avail.
I need to be able to create a custom list like List. I know you can do it in C# but I need it in Javascript.

Hopefully there is something similar.
Thanks

4 Answers

4

I think you are looking for this…?

Greetz, Ky.

I take that as crazy-in-a-good-way? ^^

If you are speaking of C# then “List” is not a function but a collection. In JS you can use Array which serves the same purpose (for instance you can push and pop elements dynamically), although it does provide the same amount possibilities.

Array is not really what I need. I need something that do the equivalence of List<MyClass>.

Huh? What? I have no problem using lists in uJS. Is this a recent thing, then?

import System.Collections.Generic;

public var myList : List.<TYPE>; // Insert TYPE

See the date on the question? 2011. (Although I believe generics did work back then.)

Aye that's why I asked if Lists in uJS were recent :) Anyhoo - Closing

This might help: http://www.w3schools.com/js/js_obj_array.asp

20/12/2014 - error 404 :(

Yeah, don't learn Unity coding from W3Schools JS. It's not what you need.