相关疑难解决方法(0)

在javascript中的hasOwnProperty

function Shape() {
    this.name = "Generic";
    this.draw = function() {
        return "Drawing " + this.name + " Shape";
    };
}

function welcomeMessage()
{
    var shape1 = new Shape();
    //alert(shape1.draw());
    alert(shape1.hasOwnProperty(name));  //this is returning false
}
Run Code Online (Sandbox Code Playgroud)

.welcomeMessage呼吁这个body.onload事件.

我期望shape1.hasOwnProperty(name)返回true,但它返回false.

什么是正确的行为?

javascript

73
推荐指数
2
解决办法
13万
查看次数

标签 统计

javascript ×1