Nodejs Utililty Methods Array Compact

List of utility methods to do Array Compact

Description

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

Method

compact()
Array.prototype.compact = function() {
    return this.filter(function (i) {
        return !!i;
    });
};
compact()
Array.prototype.compact = function() {
    var comp = [];
    for (var i = 0;i < this.length; i++) {
        if (this[i]) {
            comp.push(this[i]);
    return comp;
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;
};
...
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;
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;
};
...
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;
};
...