如何在调用函数时设置null上下文?

17 浏览
0 Comments

如何在调用函数时设置null上下文?

function test(){
    if(this === null){
        console.log("This is null");
    }else{
        console.log("This is Object");
    }
}
test.call(null);
test.call({});

输出:

This is Object.

This is Object.

但我期望的输出是:

This is Null.

This is Object.

为什么空值没有设置为上下文?

0