hasOwnProperty in javascript

Posted by Thiyaneshwaran S on Stack Overflow See other posts from Stack Overflow or by Thiyaneshwaran S
Published on 2010-04-08T13:17:48Z Indexed on 2010/04/08 13:23 UTC
Read the original article Hit count: 152

Filed under:
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
}

"welcomeMessage" called on the body.onload event. I expected shape1.hasOwnProperty(name) to return true. But its returning false. Whats the correct behavior?

© Stack Overflow or respective owner

Related posts about JavaScript