I find this behavior of the global window object a little weird.
var x = 10;
function SomeClass(){
var y = 15;
console.log("Someclass:y - " + this.y); //prints undefined
}
console.log("window.x: " + window.x); //prints 10
var obj = new SomeClass();
console.log("obj.y: " + obj.y); //prints - undefined
Both variables x and y are local (to window and to SomeClass respectively). Despite calling y from an object context, it only prints undefined - presumably because that is how local variables are supposed to behave. But window.x behaves differently by printing value of x. I understand that this is how you create global varibles but is this a special property of window that makes local variables behave like object variables?