Created
March 10, 2014 04:06
-
-
Save xsurge83/9459320 to your computer and use it in GitHub Desktop.
Sub class array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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