N
var items = ["item1", "item2", "item3"]
var copie = [];
items.forEach(function(item){
copie.push(item);
});
N
const object = {a: 1, b: 2, c: 3};
for (const property in object) {
console.log(`${property}: ${object[property]}`);
}
// expected output:
// "a: 1"
// "b: 2"
// "c: 3"
N
let colors = ['red', 'green', 'blue'];
for (const color of colors){
console.log(color);
}
N
const array = ['hello', 'world', 'of', 'Corona'];
for (const item of array) {
console.log(item);
}
N
const array1 = ['a', 'b', 'c'];
array1.forEach(element => console.log(element));
N
let obj = {
key1: "value1",
key2: "value2",
key3: "value3"
}
Object.keys(obj).forEach(key => {
let value = obj[key];
//use key and value here
});