Extending JavaScript's Array functionality?

Hi, I’ve currently (like I bet many of you must have) manually created a utility library for common tasks dealing with arrays, encapsulating things that may not be implemented in all browsers yet, like finding out if an element is in an array and in which position it’s at in that case.

Now I’ve started looking into adding further iterator functionality and I’ve found Underscore.js (http://underscorejs.org/). But I’m not sure which path to follow:

  • Add the whole of underscore.js to my game
  • Implement only the stuff I need by myself
  • Try and push underscore.js or just the bare minimum of useful functionalities into a common object within Cocos2D-HTML5 (maybe in somewhere like cc._, in comparison to the cc.$ borrowed from jQuery?)

What I’m trying to say is: Don’t you guys think that maybe we should add some common helpers for working with arrays as lists/enumerators into cocos2d-html5 since that would be useful in a high-level and would save each developer time and the need to look for other libraries?

Hi, @ZippoLag

As underscore is a very basic and useful library, I think it will perfectly work with Cocos2d-JS in html5 and in JSB, we don’t like to reinvent the wheel, so try to use underscore directly, personally I also love this library.

Roger that!