Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

loop elements in javascript

var list = [{a:1,b:2}, {a:3,b:5}, {a:8,b:2}, {a:4,b:1}, {a:0,b:8}];

for (var i = list.length - 1, item; item = list[i]; i--) {
  console.log("Looping: index ", i, "item", item);
}

######### ES6 Update ################

for (let item of list) {
    console.log("Looping: index ", "Sorry!!!", "item" + item);
}
Comment

loop in javascript

let num = 1
for (let i = 0; i <= 10; i++) {
	document.write(num++);
}
Comment

loop in javascript

for (var i, i = 0; i < 10 ; i++) {
  //do something
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery on wheel event 
Javascript :: http to https express js 
Javascript :: binary gap 
Javascript :: javascript change color of text input 
Javascript :: angular ngfor counter 
Javascript :: react js loop through array of objects 
Javascript :: why is my mongoose middleware not working 
Javascript :: javascript get srollwidth 
Javascript :: javas script add list 
Javascript :: toggle boolean js 
Javascript :: react native linear gradient 
Javascript :: js password generator 
Javascript :: how to prevent event capturing in javascript 
Javascript :: import svg react 
Javascript :: disable mixed content via javascript 
Javascript :: pushing element in array in javascript 
Javascript :: dynamic route vue 
Javascript :: javascript copy to clipboard 
Javascript :: java script remove last character from string 
Javascript :: foreach over array javascript 
Javascript :: js click on button 
Javascript :: react bootstrap carousel caption placement top 
Javascript :: ruby write json to file 
Javascript :: aos initial configuration vue 
Javascript :: js remove value input 
Javascript :: onchange input jquery 
Javascript :: javascript trigger event 
Javascript :: check every value in array javascript 
Javascript :: how to remove class in all siblings javascript 
Javascript :: javascript inject html 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =