Last active
February 4, 2018 04:19
-
-
Save coolreader18/748e9f8203e6985b7720eb3d455e6c0b to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Like map, but it changes the original array. | |
* @param {Function} func The function to apply to the rest of the array. Gets passed the current element, its index, and the total array. | |
*/ | |
Array.prototype.apply = function apply(func) { | |
for (var i = 0; i < this.length; i++) { | |
this[i] = func(this[i], i, this); | |
} | |
} |
This file contains 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
{ | |
"name": "array-apply", | |
"version": "1.0.0", | |
"author": "coolreader18", | |
"repo": "gist:748e9f8203e6985b7720eb3d455e6c0b", | |
"main": "array-apply.js", | |
"license": "MIT" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment