Licence
MIT
Version
0.1.0
Deps
0
Vulns
0
Weekly
0
jQuery reduce()
The classic example
var total = $.reduce([1, 2, 3], function(p, c) {
return p + c;
}, 0);
Reduce a jQuery collection into an Object
var refs = $('[ref]').reduce(function(p, c) {
p[c.attributes.ref.value] = c;
return p;
}, {});
Reduce a jQuery collection into an Array
var values = $(':text').reduce(function(p, c) {
p.push(c.value);
return p;
}, []);
The current item of the collection is the default context
var names = $(':input').reduce(function(p){
return p.concat(this.name);
}, []);