Skip to content

Instantly share code, notes, and snippets.

@ezarko
Last active March 14, 2018 01:25
Show Gist options
  • Save ezarko/9061597d709102707bfc3a3111a570ea to your computer and use it in GitHub Desktop.
Save ezarko/9061597d709102707bfc3a3111a570ea to your computer and use it in GitHub Desktop.
A jQuery reduce function which returns a proper collection object. Note that callback is called with DOM nodes that will need to be $()'d if needed.
$.fn.reduce = function() {
return (arguments.length > 1 || this.length) ? $([].reduce.apply(this.toArray(), arguments)) : this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment