Nodejs Array Each each_with_index(f)

Here you can find the source of each_with_index(f)

Method Source Code

Array.prototype.each_with_index = function (f) {
  for (var i=0; i<this.length; i++) {
    f(this[i], i)/*from   ww w  .  j  a  va2s.com*/
  }
}

Related

  1. each(visitor)
    Array.prototype.each = function(visitor) {
      var iterator = this.getIterator();
      while (iterator.hasNext()) {
        var ret = visitor.call(this, iterator.next(), iterator.current);
        if (ret === false)
          break;
    
  2. eachIndex(iterationFunction)
    Array.prototype.eachIndex = function(iterationFunction) {
        for (var i = 0; i < this.length; i++) {
            iterationFunction(this[i], i);
    };
    
  3. eachRecursive(fieldName, filterOrDoFun, doFun)
    Array.prototype.eachRecursive = function(fieldName, filterOrDoFun, doFun) {
      var filter = doFun ? filterOrDoFun : null;
      doFun = doFun || filterOrDoFun;
      var doArrayRecursive = function(arr) {
        if (!arr || !(arr instanceof Array)) {
          return;
        for (var i = 0; i < arr.length; i++) {
          var item = arr[i];
    ...
    
  4. eachWithIndex(f)
    Array.prototype.eachWithIndex = function(f) {
      for (var i = 0; i < this.length; ++i) {
        f(this[i], i);
      return this;
    
  5. each_with_index(callback)
    Array.prototype.each_with_index = function(callback) {
      for (var i=0; i < this.length; i++) { callback(this[i], i); }