Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

types of loops in javascript

//a for-of loop async-friendly
for (const element of theArray) {
    // ...use `element`...
}

//forEach  not async-friendly
theArray.forEach(element => {
    // ...use `element`...
});

//old-fashioned for loop
for (let index = 0; index < theArray.length; ++index) {
    const element = theArray[index];
    // ...use `element`...
}

//for-in
for (const propertyName in theArray) {
    if (/*...is an array element property (see below)...*/) {
        const element = theArray[propertyName];
        // ...use `element`...
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Number of documents in Mongodb 
Javascript :: get specific parent element jquery 
Javascript :: is javascript front end or backend 
Javascript :: dockerfile 
Javascript :: winston logger creating particular log file for each level 
Javascript :: add eslint dependencies for cypress 
Javascript :: jquery datatime 
Javascript :: react native vector icons not showing 
Javascript :: javascript 2 return values 
Javascript :: jquery import js file 
Javascript :: javascript range of integers 
Javascript :: react native jest snapshot 
Javascript :: polyfill for bind 
Javascript :: js add a tag inside span 
Javascript :: moment to javascript date 
Javascript :: remove duplicate value from string 
Javascript :: react prevent form submission on enter key press inside inputs 
Javascript :: js unspecified parameters 
Javascript :: how to stop re rendering in react 
Javascript :: jquery select element after this 
Javascript :: how to use saved image on react 
Javascript :: higher order function in javascript 
Javascript :: javascript resize event 
Javascript :: javascript get image dimensions 
Javascript :: react native scrollbar position issue 
Javascript :: looping queryselectorall 
Javascript :: innertext 
Javascript :: javascript code for line break after comma 
Javascript :: json object check if key exists java 
Javascript :: vue 3 route params 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =