Eric Miller
Member since Aug 6, 2014
- Profile: /members/12176-eric-miller.htm
- URL: http://simple.gy
- Comments: 4
Recent Blog Comments By Eric Miller
-
Extending JavaScript Arrays While Keeping Native Bracket-Notation Functionality
Posted on Aug 6, 2014 at 5:34 PM
I'll answer myself--looks like concat works property against the Nadel Array Extension method :) function concatWorks(x) { return [].concat(x)[0] !== x; } myCollection = new Collection(); console.log(concatWorks(myCollection)); // true... read more »
-
Extending JavaScript Arrays While Keeping Native Bracket-Notation Functionality
Posted on Aug 6, 2014 at 5:19 PM
@Ben, Have you run this test against it? function isArray(x) { return [].concat(x)[0] !== x; } I pulled it from the below StackOverflow question. Concat works against and internal and maybe unsettable property so I think it may be impossible to actually extend an array perfectly using any met... read more »
-
Extending JavaScript Arrays While Keeping Native Bracket-Notation Functionality
Posted on Aug 6, 2014 at 5:07 PM
@Gordon, Check out Backbone's extend implementation. You should be able to write both the array extension and an extend method on your base Collection class. http://backbonejs.org/docs/backbone.html#section-206 I am trying to translate Ben's code into this use case now.... read more »
-
Extending JavaScript Arrays While Keeping Native Bracket-Notation Functionality
Posted on Aug 6, 2014 at 5:03 PM
I'm here to figure out how to fix the .concat method. As a note, @BobGray's method works, but only in one direction. Here's what I mean: If you use this to fix concat: Catalog.prototype.concat = function () { return Array.prototype.concat.apply( this.slice(), arguments ); }; Then th... read more »