Nodejs Array Except except(arr, comparer)

Here you can find the source of except(arr, comparer)

Method Source Code

Array.prototype.except = function (arr, comparer) {
    if (!(arr instanceof Array)) arr = [arr];
    comparer = comparer || EqualityComparer;
    var l = this.length;
    var res = [];
    for (var i = 0; i < l; i++) {
        var k = arr.length;
        var t = false;
        while (k-- > 0) {
            if (comparer(this[i], arr[k]) === true) {
                t = true;//ww  w .j  ava  2  s. c om
                break;
            }
        }
        if (!t) res.push(this[i]);
    }
    return res;
};

Related

  1. except(ary)
    Array.prototype.except = function (ary) {
        var result = new Array();
        this.forEach(x => {
            if (!ary.contains(x))
                result.push(x);
        });
        return result;
    };
    
  2. except(cleanIndex)
    Array.prototype.except = function (cleanIndex) {
      return this
        .filter((value, index) =>
          (typeof cleanIndex === 'object')
            ? cleanIndex.indexOf(index) === -1
            : index !== cleanIndex);
    console.log(
      ['a', 'b', 'c', 'd', 'e'].except([0, 1]), 
    ...
    
  3. except(filter)
    Array.prototype.except = function(filter) {
      var elements = this.filter(function(element) {
        return element != filter
      });
      return elements
    
  4. except(keys)
    Array.prototype.except = function(keys)
      let arr = this.map((i) => i);
      if(keys.length) {
        keys.sort((a,b) => a - b);
        keys.forEach((k, i) => { arr.splice(k - i, 1);});
      } else {
        arr.splice(keys, 1);
      return arr;