for in for in javascript code example
Example 1: javascript for
let str = "";
for (let i = 0; i < 9; i++) {
str = str + i;
}
console.log(str);
// expected output: "012345678"
Example 2: for in javascript
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"
Example 3: for in javascript
for (let i = start; i < end; i++) {
}
Example 4: javascript for of
const numbers = [1,2,3,4];
for(const item of numbers){
console.log(item);
}