Applies function to all pairs in array - Node.js Array

Node.js examples for Array:Array Value

Description

Applies function to all pairs in array

Demo Code


/* Applies function to all pairs */
Array.prototype.eachPair = function(func){
  for(var i=0; i < this.length; i++){
    for(var j=i+1; j < this.length; j++){
      func.call(this, i, j);/*w ww.  j  av a  2 s .  c o m*/
    }
  }
}

Related Tutorials