Created
August 25, 2016 22:21
-
-
Save ernix/e698e14598d902b5fc052a5146c7edcd to your computer and use it in GitHub Desktop.
jQuery.reduce()
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
$.fn.extend({ | |
reduce: function (cb, init) { | |
this.each(function (i) { | |
if (i === 0 && typeof init === 'undefined') { | |
init = $(this); | |
} else { | |
init = cb.call($(this), init); | |
} | |
}); | |
return init; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment