- Forums
- Javascipt
- For Loops - How To Loop A Javascript Object In React Or Sharepoint
This Page Contains information about For Loops - How To Loop A Javascript Object In React Or Sharepoint By jj in category Javascipt with 0 Replies. [5159], Last Updated: Mon Jun 24, 2024
jj
Wed Jun 14, 2023
0 Comments
405 Visits
you can use these loops are references if you need to irriritate a javascript object.
// LOOP SHAREPOINT API OBJECT
for (let [property, value] of Object.entries(objName)){
}
// LOOP ARRAY
for (let index = 0; index < array.length; index++) {
const element = array[index];
loop
}
// OF
let colors = ["red", "blue","green"];
for(let color of colors){
console.log(color); // "red", "blue","green"
}
// IN
let colors = ["red", "blue","green"];
for(let index in colors){
console.log(colors[index]); //"red", "blue","green"
}
// IN
nameObj = {"first":"John","last":"smith"}
for (var key in nameObj) { var value = nameObj[key];
alert('key='+key+' | value='+value);
}