10 examples of 'jquery foreach loop' in JavaScript

Every line of 'jquery foreach loop' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
79function forEach(array, callback, scope) {
80 for (var i = 0; i < array.length; i++) {
81 callback.call(scope, i, array[i]); // passes back stuff we need
82 }
83}
389function forEach (array, callback, thisObj)
390{
391 for (var i=0; i
11function forEach(array, callback, scope, splice) {
12 for (var all = [].concat(array), index = 0, length = all.length; index < length; ++index) {
13 if (splice) {
14 array.splice(index, 1);
15 }
16
17 callback.call(scope, all[index], index, array, scope);
18 }
19}
66function jQueryGenericLoop (elements, cache) {
67 $.each( cache, function ( key, val ) {
68 if ( val.handle ) {
69 jQueryGeneric(elements, val, val.handle.elem);
70 }
71 } );
72}
6function forEach(arr, callback, thisObj) {
7 if (arr == null) {
8 return;
9 }
10 var i = -1,
11 n = arr.length;
12 while (++i < n) {
13 // we iterate over sparse items since there is no way to make it
14 // work properly on IE 7-8. see #64
15 if ( callback.call(thisObj, arr[i], i, arr) === false ) {
16 break;
17 }
18 }
19}
9function _Array_forEach(array, block, context) {
10 if (array == null) return;
11 //对String进行特殊处理
12 if(typeof array == 'string'){
13 array = array.split('');
14 }
15 var i = 0,length = array.length;
16 for (;i < length && block.call(context, array[i], (i+1), array)!==false; i++) {}
17};
782function forEach(callback, context){
783 var index = 0,
784 self = this;
785 mforEach(unwrap(this), function(key){
786 call(callback, this, key, index++, self);
787 }, context);
788}
35function foreach(arr, fn) {
36 if (!arr) return;
37
38 if (arr instanceof Array) {
39 for (var i=0; i
25function forEach(object, callback, context) {
26 var index, length;
27 if (object.length) {
28 if (Array.prototype.forEach) {
29 Array.prototype.forEach.call(object, callback, context);
30 } else {
31 for (index = 0, length = object.length; index < length; index += 1) {
32 callback.call(context || this, object[index], index, object);
33 }
34 }
35 } else {
36 for (index in object) {
37 if (object.hasOwnProperty(index)) {
38 callback.call(context || this, object[index], index, object);
39 }
40 }
41 }
42}
77function iterate(index, array, result) {
78 if (index >= array.length) {
79 return result;
80 } else return callback(array[index], index).then(function (res) {
81 result.push(res);
82 return iterate(index + 1, array, result);
83 });
84}

Related snippets