map()
by sikusikucom
JavaScript
var tweeps = [
{ name: 'Marge', age: 30 },
{ name: 'Lisa', age: 15 }
];
// using a typical for-loop to print each name
for (var i = 0; i < tweeps.length; i++) {
console.log(tweeps[i].name);
}
// you can use this too
for (var x in tweeps) {
console.log(tweeps[x].name);
}
// a simpler way, using map()
tweeps.map(function(tweep) {
console.log(tweep.name)
});