10 examples of 'foreach class jquery' in JavaScript

Every line of 'foreach class jquery' 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
this disclaimer
6function each(els, callback) {return Array.prototype.forEach.call(els, callback);}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

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}
90function _each(fnName, className) {
91 _each2.each(this, function (element) {
92 element.classList[fnName](className);
93 });
94}
389function forEach (array, callback, thisObj)
390 {
391 for (var i=0; i<array.length; i++)
392 {
393 if (array.hasOwnProperty(i))
394 {
395 callback.call(thisObj, array[i], i, array);
396 }
397 }
398}
35function foreach(arr, fn) {
36 if (!arr) return;
37
38 if (arr instanceof Array) {
39 for (var i=0; i<arr.length; i++) {
40 fn(arr[i], i);
41 }
42 } else {
43 for (attr in arr) {
44 fn(arr[attr], attr);
45 }
46 }
47}
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}
30function each(array, fn) {
31 if (typeof array.forEach === "function") return array.forEach(fn);
32
33 for (var i = 0; i < array.length; i++) fn(array[i], i);
34}
110function forEach(elements, callback) {
111 Array.prototype.forEach.call(elements, callback);
112}
8function $$each(selector, func) { [].forEach.call($$(selector), func) }
102function each (arr, fn) {
103 if (Array.prototype.forEach) {
104 arr.forEach(fn)
105 } else {
106 let i = 0,
107 len = arr.length
108 for (; i < len; i++) {
109 fn(arr[i], i)
110 }
111 }
112}

Related snippets