Nodejs Array Same same(comparisons, unordered)

Here you can find the source of same(comparisons, unordered)

Method Source Code

Array.prototype.same = function(comparisons, unordered) {
    // [1, 9].same([9, 1]);
    // [1, 9].same([9, 1], true);
    // [1, 9].same([9, 1], false);
    // [1, 9].same([1, 9]);
    // [1, 9].same([1, 9], true);
    // [1, 9].same([1, 9], false);
    // [1, 9].same([1, 9], [9, 1]);
    // [1, 9].same([1, 9], [9, 1], true);
    // [1, 9].same([1, 9], [9, 1], false);
    // [1, 9].same([1, 9], [1, 9]);
    // [1, 9].same([1, 9], [1, 9], true);
    // [1, 9].same([1, 9], [1, 9], false);
    // [].same([]);
    // [].same([], true);
    // [].same([], false);
    // [].same([]);
    // [].same([], []);
    // [].same([], [], true);
    // [].same([], [], false);

    // Prototypes throw TypeErrors when the context or arguments are invalid

    if (Object.prototype.toString.call(this) !== '[object Array]') {
        throw new TypeError("`this` must be Array, not " + typeof this);
    }//from  w w  w  . j av a2s . c  om

    var arglen = arguments.length;

    if (arglen < 1) {
        throw new TypeError("`arguments` must have at least one comparison `Array`");
    }

    var firstarg = arguments[0];

    if (arglen === 1 && Object.prototype.toString.call(firstarg) !== '[object Array]') {

    }

    var lastarg = arguments[arguments.length - 1],
        typeof

    if (arguments.length >= 2) {
        var lastArg = arguments[arguments.length - 1];

        if (typeof arguments[arguments.length - 1] === 'boolean') {

        }
    }


};

Related

  1. same()
    Array.prototype.same = function() {
        for(var i = 1; i < this.length; i++) {
            if(this[i] !== this[0])
                return false;
        return true;
    
  2. same(obj)
    Array.prototype.same = function(obj) { 
        var i = this.length;
        while (i--) {
            if (obj.contains(this[i])) {
        return false;
    };
    
  3. sameElementCount(arr)
    Array.prototype.sameElementCount = function(arr) {
      var result = [], count = null;
      arr.sort();
      for (var i = 0; i < arr.length;) {
        count = 1;
        for (var j = i + 1; j < arr.length; j++) {
          if (arr[i] == arr[j]) {
            count++;
        result.push([ arr[i], count ]);
        i += count;
      return result;
    };
    
  4. same_values(arr)
    function findMissing(arr1, arr2){
      if((arr1.length) && (arr2.length) === 0){
        return 0;
      if(arr1.same_values(arr2)){
        return 0;
      for(num = 0; num < arr2.length; num++){
        if(isInArray(arr2[num], arr1) !== true) return arr2[num];
    ...