Nodejs Utililty Methods Array Collect

List of utility methods to do Array Collect

Description

The list of methods to do Array Collect are organized into topic(s).

Method

collect( func )
Array.prototype.collect = function( func ) {
  if( $.isFunction(func) ) {
    var _arr = [];
    for( var i=0; i<this.length; i++ ) {
      var item = this[i];
      var o = func(item);
      if(o!=null) _arr.push(o);
    return _arr;
...
collect(collectFunction)
Array.prototype.collect = function(collectFunction) {
    return this.inject([], function(result, element) {
        result.push(collectFunction(element));        
        return result;
    });
};
collect(fn)
Array.prototype.collect = function(fn) { 
  var result = [];
  for (var i = 0; i < this.length; i += 1) {
    result.push(fn(this[i]));
  return result;
};
collect(fn)
Array.prototype.collect = function(fn) {
  var a = [];
  for(var i = 0; i < this.length; i++) {
    a.push(fn(i, this[i]));
  };
  return a;
};
collect(fun)
Array.prototype.collect = function(fun) {
    var result = [];
    this.each(function(it) {
        result.push(fun(it));
    });
    return result;
};
collect(operation)
Array.prototype.collect = function(operation) {
    var derivedArray = [];
    for (i = 0; i < this.length; i += 1) {
        derivedArray.push(operation(this[i]));
    return derivedArray;