链家笔试题总结

论坛 期权论坛 脚本     
匿名技术用户   2020-12-27 01:22   421   0

一、

var name="abc";
var person={
    name:'cba',
    getName:function () {
        return this.name;
    }
}
console.log(person.getName());
var p1=person.getName;
console.log(p1());
var p2=new p1();
console.log(p2.name);

二、

var v='cba';
(function () {
    var v='abc'
    function A() {
        var v='a'
        this.getV=function () {
            console.log(v);
        }
    }
    function B() {
        var v='b'
        A.call(this);
    }
    var b=new B();
    b.getV();
}())

三、

var i=1;
(
    function () {
        var s = new Date().getTime();
        var si = setInterval(function () {
            var n =  new Date().getTime();
            if(n <(s+100)){
                i++;
            }else{
                console.log(i);
                clearInterval(si);
            }
        },10)
    }
)()

四、

var foo=1;
function main() {
    console.log(foo);
    var foo=2;
    console.log(this.foo);
    this.foo=3;
}
main();
new main()

五、

function one() {
    this.name = 1;
    function two() {
        this.name = 2;
        function three() {
            var name = 3;
            console.log(this.name);
        }
        return three;
    }
    return two;
}
one()()();

六、

这里写代码片
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP