Please check the code in http://jsfiddle.net/4a42n8g8/. it alerts "undefined". Why? I have 2 questions in particular.
var a = 10;
function x() {
a = 20;
alert(this.a);
}
x();
1) Isn't the variable "a" within function x a global variable since it does not have a var prefix? Or is it that with or without var prefix, any variable within a function is not a global variable?
2) Since var a = 10 is defined outside the function, doesn't it make it a global variable? Or is it that all global variables SHOULD NOT have a var prefix?