面试题

var v = 123;
function foo(){
    var v = 456;
    function inner(){
        console.log(v)
    }
    return inner
}

result = foo()
console.log(result()) 

# 问输出结果://456

Name='root';
Age = 18;
function Foo(name,age){
    this.Name = name;
    this.Age = age;
    this.Func = function(){
        console.log(this.Name,this.Age);
        (function(){
             console.log(this.Name,this.Age);
        })();
    }
}
obj = new Foo('alex',666);
obj.Func()

# 问输出结果:
// alex 666
// root 18

 

posted @ 2019-04-11 15:01  狂奔~  阅读(83)  评论(0编辑  收藏  举报