x


[Closed] 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

more ▼

asked Sep 12, 2011 at 01:18 AM

avatar image

BrandonLayton
1 5 6 8

(comments are locked)
10|3000 characters needed characters left

The question has been closed Dec 20, 2014 at 07:04 PM by meat5000 for the following reason:

Problem outdated


4 answers: sort voted first
more ▼

answered Sep 13, 2011 at 10:54 AM

avatar image

SisterKy
3.3k 81 94 167

uh, Unity (or Mono) adds features like those collections to JS? That is crazy, actually

Sep 13, 2011 at 11:51 AM japanitrat

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

Sep 13, 2011 at 11:59 AM SisterKy

indeed ;) but i wonder where this is documented (except for the collections)

Sep 13, 2011 at 12:13 PM japanitrat
(comments are locked)
10|3000 characters needed characters left
more ▼

answered Feb 26, 2013 at 06:04 AM

avatar image

timrox99
0 1 3 5

20/12/2014 - error 404 :(

Dec 20, 2014 at 06:29 PM gregorio80

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

Dec 20, 2014 at 06:36 PM meat5000
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Sep 12, 2011 at 01:25 AM

avatar image

japanitrat
99 4 5 10

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

Sep 12, 2011 at 09:46 PM BrandonLayton

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 Ky, Unity or Mono do enhance the common JS stuff.

Sep 13, 2011 at 09:22 AM japanitrat
(comments are locked)
10|3000 characters needed characters left

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
more ▼

answered Dec 20, 2014 at 06:35 PM

avatar image

meat5000
21.7k 855 30 75

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

Dec 20, 2014 at 07:02 PM Eric5h5

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

Anyhoo - Closing

Dec 20, 2014 at 07:04 PM meat5000
(comments are locked)
10|3000 characters needed characters left

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x6836
x1009
x128

asked: Sep 12, 2011 at 01:18 AM

Seen: 41915 times

Last Updated: Dec 20, 2014 at 07:04 PM