Attaching variables to the window object

Concepts and other code to remember

Some interesting logs to the console. I took a few seconds to ponder the following boolean interrogations after watching this video here.

var a = 1;
var b = "Jack";

function foo(){
    var a = "Jack"
    console.log(window.a);
    console.log(a);
    console.log(this.a);
    console.log(window.a == a);
    console.log(this.a == window.a);
    console.log(a == window.b);
    console.log(b == a);
    console.log(this.b == this.a);
};

foo();

Results in… (click to enlarge)


Screen Shot 2015-02-10 at 4.21.41 PM