0
I am not able to understand why the loop below works to assign a new value to the index, but does not work to change the property of an object. What I did wrong, you guys?
var p = ["teste1", "teste2", "teste3", "teste4"];
for (var key in p) {
if (p.hasOwnProperty(key)) {
console.log(key + " -> " + p[key]); // AQUI O LAÇO FUNCIONA.
var people = [
{
name: p[key],
url: "http://example.com/johnsmith"
}
];
console.log(people[key]); // AQUI O LAÇO NÃO FUNCIONA. =\
}
}
Exactly as you guessed, Lucas! Thank you very much for the tip, my dear!
– winiercape
Not to mention I didn’t know the push method()! :)
– winiercape
Glad I could help! ;)
– Lucas Samuel