SOURCE

// 1. 
// var name = '222';
// var a = {
//     name: '111',
//     say: function () {
//         console.log(this.name);
//     }
// }
// var fun = a.say; // 将say函数拿到全局声明
// fun();
// a.say()

// var b = {
//     name: '333',
//     say: function (fun) {
//         // console.log(this)
//         // this --> b
//         // 但是这里执行时没有this指向,所以会调用全局的this --> window
//         // 222
//         fun();
//     }
// }
// b.say(a.say);
// b.say = a.say;
// b.say();

// 2. 
// var foo = '123';
// function printf () {
//     var foo = '456';
//     this.foo = '789';
//     console.log(foo);
// }
// printf();

// 3. 
// var foo = '123';
// function printf () {
//     this.foo = '234';
//     console.log(foo);
// }
// printf();
// // new printf(); // var this = Object.create(printf.prototype)

// 4. 
// 运行test()和new test()的结果分别是什么
var a = 5;
function test () {
    a = 0;
    console.log(a);
    console.log(this.a);
    var a;
    console.log(a);
}
// test();
// AO: {
//     a: 0,
//     this: window
// }
new test();
// AO: {
//     a: 0,
//     this: {
//         __proto__: test.prototype
//     }
// }





console 命令行工具 X clear

                    
>
console