Function scope 

function sayHello() {
    var greeting = "Hello world!";
    alert(greeting);
}
window.sayHello = function () {
    var greeting = "Hello world!";
    alert(greeting);
};