- Home /
Problem outdated
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
Answer by SisterKy · Sep 13, 2011 at 10:54 AM
I think you are looking for this...?
http://www.unifycommunity.com/wiki/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use%3F
Greetz, Ky.
uh, Unity (or $$anonymous$$ono) adds features like those collections to JS? That is crazy, actually
indeed ;) but i wonder where this is documented (except for the collections)
Answer by meat5000 · Dec 20, 2014 at 06:35 PM
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
Answer by timrox99 · Feb 26, 2013 at 06:04 AM
This might help: http://www.w3schools.com/js/js_obj_array.asp
Yeah, don't learn Unity coding from W3Schools JS. It's not what you need.
Answer by japanitrat · Sep 12, 2011 at 01:25 AM
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<$$anonymous$$yClass>
.
JavaScript has no generics, so the answer is no. But you can put all kinda things into a JS Array, its just not type-safe.
Edit: as pointed out by $$anonymous$$y, Unity or $$anonymous$$ono do enhance the common JS stuff.
Follow this Question
Related Questions
A node in a childnode? 1 Answer
JS Argument out of range 1 Answer
Is there eval() for C#? 2 Answers
How to set parents of all objects in an array? 1 Answer
List problem? 2 Answers