I'm trying to access the properties of this object:
var obj = {hello: 1, world: 2};
This gives me back undefined:
function foo(a) {
for(property in a) {
console.log(a.property);
}
return "foo";
}
foo(obj);
This gives the intended result:
function bar(a) {
for(property in a) {
console.log(a[property]);
}
return "bar";
}
bar(obj);
Why does the call to foo not work, while the call to bar allows me to access the properties?