List of utility methods to do Array Extract
extract(attribute)"use strict"; Array.prototype.extract = function(attribute) { var newArr = []; for (var i = 0; i < this.length; i++) { newArr.push(this[i][attribute]); return newArr; | |
extract(field)Array.prototype.extract = function(field) { var newArray = []; for (var i = 0; i < this.length; i++) { if (this[i][field] != undefined) { newArray.push(this[i][field]); return newArray; }; ... | |
extract(predicate)Array.prototype.extract = function(predicate) { var removed = []; if (this.length===0 || !predicate || typeof predicate !== 'function') { return removed; var idx = 0; while(idx < this.length) { if (predicate(this[idx])) { removed.push(this[idx]); ... |