function getForFunction(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
return obj[key];
}
}
}
console.log(getForFunction({a: 1, b: 2, c: 3}));
1
2
3
function getForFunction(obj, callback) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
callback(obj[key]);
}
}
}
getForFunction({a: 1, b: 2, c: 3}, function( i ){
console.log(i);
});