I'm trying to use underscore in an OO way:
var myCollection = _([]);
myCollection.push('one');
myCollection.push('two');
myCollection.push('three');
How do I get the item at a numeric index? I'm sure I'm missing something, other than using myCollection.toArray()[1]
. There's no myCollection.get(1)
?
Also, if I use myCollection.push('something')
, it returns an array
, which isn't chainable. I'm really confused why there isn't something out there like this already.
As a follow up to this question, I'm trying to use underscore in an OO way, and not have to rewrap the array/object every time. After some of these challenges, it appears its not really meant to be used this way?
So now I'm wondering, is there a better library that has a generic, chainable, OOP, collection wrapper?