Skip to content

Instantly share code, notes, and snippets.

@MD4
Last active July 20, 2016 09:36
Show Gist options
  • Save MD4/c744443b5cf2bc283769dfdfd3653f14 to your computer and use it in GitHub Desktop.
Save MD4/c744443b5cf2bc283769dfdfd3653f14 to your computer and use it in GitHub Desktop.
🐒 Chainable forEach monkey patch !
(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
@MD4
Copy link
Author

MD4 commented Jun 8, 2016

🐵

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment