Created
April 3, 2012 12:16
-
-
Save fcamblor/2291520 to your computer and use it in GitHub Desktop.
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
| // Array Remove - By John Resig (MIT Licensed) | |
| // See http://ejohn.org/blog/javascript-array-remove/ | |
| Array.prototype.remove = function(from, to) { | |
| var rest = this.slice((to || from) + 1 || this.length); | |
| this.length = from < 0 ? this.length + from : from; | |
| return this.push.apply(this, rest); | |
| }; | |
| // "Ghosting" remove function in order to not iterate over it during a for(.. in ..) loop | |
| // on arrays | |
| if(Object && Object.defineProperty){ | |
| // Will change "enumerable" metadata for Array.prototype.remove() function | |
| Object.defineProperty(Array.prototype, "remove", { writable: false, enumerable: false }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment