Skip to content

Instantly share code, notes, and snippets.

@xsurge83
Created March 10, 2014 04:06
Show Gist options
  • Select an option

  • Save xsurge83/9459320 to your computer and use it in GitHub Desktop.

Select an option

Save xsurge83/9459320 to your computer and use it in GitHub Desktop.
Sub class array
function _bindArrayMethod(name, obj) {
obj.prototype[name] = function () {
return Array.prototype[name].apply(this, arguments);
};
}
function subClassArray(obj) {
var index;
for (index = 0; index < methods.length; index++) {
_bindArrayMethod(methods[index], obj);
}
return obj;
}
function MyArray(array) {
this.push.apply(this, array);
}
subClassArray(MyArray);
MyArray.prototype.length = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment