技术知识

前端面试题2

2016-09-03  本文已影响122人  drunkcat2020

前端面试题2

    (function() {
        var a = b = 5;
    })();
    console.log(b);
    console.log(a);
    function foo() {
        var i = 0;
        return function() {
            console.log(i++);
        }
    }
    var f1 = foo;
    var f2 = foo;
    f1();
    f1();
    f2();
    var myObject = {
        foo:'bar',
        fun:function() {
            var self = this;
            console.log(this.foo);//bar
            console.log(self.foo);//bar
            (function() {
                console.log(this.foo);//undefined
                console.log(self.foo);//bar
            }());
    if(!"a" in window) {
        var a = 1;
    }
    alert(a);
上一篇下一篇

猜你喜欢

热点阅读