Skip to content

Instantly share code, notes, and snippets.

@ernix
Created August 25, 2016 22:21
Show Gist options
  • Save ernix/e698e14598d902b5fc052a5146c7edcd to your computer and use it in GitHub Desktop.
Save ernix/e698e14598d902b5fc052a5146c7edcd to your computer and use it in GitHub Desktop.
jQuery.reduce()
$.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