javascript array choices

Just making sure I understand - i’m still a newb:

Native/builtin arrays :
var a = new float[1024];
+is very fast
-fixed size and type

Javascript arrays:
var a = new Array(1024);
-more overhead

  • takes any type
  • grows and has methods documented in ScriptReference/Array.html
    Can be quickly converted to native using ToBuiltin() method!
    I gather this is a builtin array with some helper methods added?

ArrayList:
var a = new ArrayList(1024);
–even more overhead

So for example, if I need a Contains() method and it’s NOT a performance critical script then I go with ArrayList, right?

I don’t know for sure, but I’d expect UnityEngine.Array to be a Javascript-friendly wrapper for ArrayList. I certainly wouldn’t expect ArrayList to be any slower.

EDIT: having looked a little closer, using the .NET Reflector app, I’m pretty sure that UnityEngine.Array really is just a wrapper for ArrayList. Therefore ArrayList will be fractionally faster because you won’t have to go through the wrapper’s function calls. That’s hardly likely to be a concern, though, so you should just use whichever is most comfortable.