I am looping over a simple object using forEach
function, I'm passing the object as the context.
When I try to access an object property using this[key]
it works but this.key
doesn't work, can someone tell us why it behaves so?
var calendar = {
moveAll: false,
moveSingleDay: false,
translateRange : false
}
angular.forEach(calendar, function(val, key){
console.log(this[key]); // returns val
console.log(this.key); // returns undefined
}, calendar);