I have the following function. The javascript tutorial I'm reading says it should output 2, but I'm getting undefined in my text editor (JS Fiddle).
What could be the reason? Does this have something to do with strict mode vs non-strict mode?
function foo(){
console.log( this.a );
}
var a = 2;
foo(); //should output "2" but I'm getting undefined. Why?