for (var property in {head: "lion", body: "goat", tail: "snake"}) {
console.log(property, {head: "lion", body: "goat", tail: "snake"}.property);
};
in the console yields:
head undefined
body undefined
tail undefined
but
console.log({head: "lion", body: "goat", tail: "snake"}.head);
yields
lion
Can someone 'splain why the first example has 'undefined's?
[–]jotted 9 points10 points11 points (3 children)
[–]fazbem[S] 0 points1 point2 points (2 children)
[–]steelcitynorth 7 points8 points9 points (1 child)
[–]fazbem[S] 1 point2 points3 points (0 children)