jq-reduce

0.1.0 • Public • Published

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);
}, []);

Readme

Keywords

none

Package Sidebar

Install

npm i jq-reduce

Weekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • cizar