Last active
July 20, 2016 09:36
-
-
Save MD4/c744443b5cf2bc283769dfdfd3653f14 to your computer and use it in GitHub Desktop.
🐒 Chainable forEach monkey patch !
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
(function(oldForEach) { | |
Array.prototype.forEach = function() { | |
oldForEach.apply(this, arguments); | |
return this; | |
}; | |
}(Array.prototype.forEach)); | |
[1, 2, 3] | |
.forEach(item => console.log(1, item)) | |
.forEach(item => console.log(2, item)) | |
// 1 1 | |
// 1 2 | |
// 1 3 | |
// 2 1 | |
// 2 2 | |
// 2 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🐵