Nodejs Array Compact compacted()

Here you can find the source of compacted()

Method Source Code

////from w  w w  .j av a  2  s .  c  o m
// Array extensions
//
Array.prototype.compacted = function () {
    var tmp = [];
    for (var i = 0; i < this.length; i++) {
        if (this[i] !== undefined && this[i] !== null && this[i] !== false) {
            tmp.push(this[i]);
        }
    }
    return tmp;
};

Related

  1. compact()
    Array.prototype.compact = function() {
        return this.filter(function (i) {
            return !!i;
        });
    };
    
  2. compact()
    Array.prototype.compact = function() {
        var comp = [];
        for (var i = 0;i < this.length; i++) {
            if (this[i]) {
                comp.push(this[i]);
        return comp;
    
  3. compact(deleteValue)
    Array.prototype.compact = function(deleteValue) {
      for (var i = 0; i < this.length; i++) {
        if (this[i] == deleteValue) {
          this.splice(i, 1);
          i--;
      return this;
    };
    ...
    
  4. compact(fn)
    Array.prototype.compact = function(fn) {
      for (var i = 0; i < this.length; i++)
        if (this[i] == null) {
          this.splice(i, 1);
      return this;
    
  5. compacted()
    Array.prototype.compacted = function () {
        var tmp = [];
        for (var i = 0; i < this.length; i++) {
            if (this[i] !== undefined && this[i] !== null && this[i] !== false) {
                tmp.push(this[i]);
        return tmp;
    };
    ...