One: The difference between a for loop and for
The for...in statement is used to loop an array or an object's properties.
Grammar:
For (variable in object)
{
Execute code here
}
A For loop is a loop of elements of an array, and cannot be cited for non-object arrays (class array objects can also traverse).
Grammar:
for (int variable initial value; condition; increment or decrement) {
Execute code here
}
Iterates through the properties of the Window object with for.
for (var in window) { console.log (Winodw[prop])}
Iterates over the array elements with a for inb.
for (var in array) { console.log (Array[ele]);}
Implemented with a For loop
for (var i=0;i<array.length;i++) { alert (array[i]); // elements of an array }
the best tool for detecting types is: typeof
Two: $ ('). The difference between each and $.each$ (").
Each () method specifies the function to run for each matching element.
Tip: Return False to Stop the loop early.
$ (selector). each (function (index,element))
- Index-the index position of the selector
- Element-current elements (can also use the "this" selector)
$.each
iterates over the property values of an object, an array, and processes it.
var arr1 = ["AAA", "BBB", "CCC" ]; function (i,val) { alert (i); Alert (val); });
For loop with for in,$ ('). The difference between each and $.each