Ad
  • Custom User Avatar

    Well, two ideas came to my mind.

    First. You just override Array.prototype.reduce and Array.prototype.concat to your function that will throw an error, you can't use this method or something simillar.

    Second, you still override it, but with an inner counter of invokes. You would assing these functions to a variables and on the prototype you would write your own function simillar to this.

      var originalReduce = Array.prototype.reduce, reduceCounter = 0;
      Array.prototype.reduce = function () {
        reduceCounter++;
        return originalReduce;
      }
    

    The test would check the counter if it has changed. In my mind this works, but you would have to check that for yourself ;).