JavaScript Loop через массив
var colors = ["red","blue","green"];
colors.forEach(function(color) {
console.log(color);
});
Gifted Gerenuk
var colors = ["red","blue","green"];
colors.forEach(function(color) {
console.log(color);
});
var person={
first_name:"johnny",
last_name: "johnson",
phone:"703-3424-1111"
};
for (var property in person) {
console.log(property,":",person[property]);
}
var subjects = {
'math': 85,
'physics': 75,
}
for (var i in subjects) {
console.log(i + ' : ' + subjects[i]);
}
// math : 85
// physics : 75
//basic for in loop
const car = {
carName: "Ford",
carDoor: 4,
carSpeed: 180
}
for (objKey in car) {
console.log(car[objKey])
}
//output
Ford
4
180
let arry = {
name: "Rakibul Islam",
class: "Tane",
grup: "A",
roll: 10,
sub: "Arse"
}
//for in loop used to object
for(let i in arry){
console.log(i,arry[i]);
}
//Objeto
var obj = {a:1, b:2, c:3};
//Para prop (propriedade) in obj (objeto) faça
for (var prop in obj) {
// ctrl+shift+k (para abrir o console no mozilla firefox)
console.log("obj." + prop + " = " + obj[prop]);
}
//A saída (output) deverá ser:
// "obj.a = 1"
// "obj.b = 2"
// "obj.c = 3"