Nodejs Array Each each(func, scope)

Here you can find the source of each(func, scope)

Method Source Code

Array.prototype.each = function(func, scope) {
    for (var index = 0; index < this.length; index++) {
        func.call(scope || this, this[index]);
    }/*from   www  .j  a  v  a2  s . co  m*/
};

Related

  1. each(fun)
    function emptyFn() {}
    function random(n) {
        return +n ? Math.floor(Math.random() * (n+1)) : Math.random();
    Array.prototype.each = Object.prototype.each = Function.prototype.each = function(fun) {
        for (var key in this) {
            if (this.hasOwnProperty && this.hasOwnProperty(key)) {
                if (fun.call(this, this[key], key, this) === false) {
                    return;
    ...
    
  2. each(func)
    Array.prototype.each = function (func) {
        return _.each(this, func);
    };
    
  3. each(func)
    Array.prototype.each = function(func) {
      function each(array, func) {
      for (var i=0; i<array.length; ++i) {
        func.call(array[i], i);
     each(this, func); 
    };
    
  4. each(func)
    Array.prototype.each = function (func) {
      var arr = this;
      for (var i = 0; i < arr.length; i++) {
        func(arr[i]);
    
  5. each(func)
    Array.prototype.each = function(func) {
      for(var i = 0; i < this.length; i++)
        func(this[i]);
    
  6. each(handler, context)
    Array.prototype.each = function (handler, context) {
        var size = this.length
        if (typeof context == "undefined") context = this
        for (var i = 0; i < size; i++) {
            if (handler.call(context, this[i], i) == false) break
    
  7. each(iterationFunction)
    Array.prototype.each = function(iterationFunction) {
        this.eachIndex(function(element, index) {
            iterationFunction(element);
        });
    };
    
  8. each(iterator)
    Array.prototype.each = function(iterator) {
      for(var i = 0; i < this.length; i++) {
        iterator(this[i], i);
    
  9. each(iterator, context)
    Array.prototype.each = function(iterator, context)
      for(var i = 0, length = this.length >>> 0; i < length; i++)
        if(i in this)
          if(iterator.call(context, this[i], i, this) === false)
            return;