loop through array pogf operations javascript code example
Example 1: iterate through array javascript
var myStringArray = ["Hello","World"];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
console.log(myStringArray[i]);
}
Example 2: javascript loop through array
Array.prototype.myEach = function(callback) {
for (let i = 0 ; i < this.length ; i ++) {
callback(this[i]);
}
}
let array = ['Item 1', 'Item 2', 'Item 3', 'Item 4'];
array.myEach(function (element) {
console.log(element);
});