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
이벤트는 body.onload
이벤트에서 호출됩니다.자바 스크립트의 hasOwnProperty
shape1.hasOwnProperty(name)
이 true를 반환하지만 false가 반환 될 것으로 예상했습니다.
올바른 동작은 무엇입니까?
그것이 문자열이 필요, 반대로 너무 ' "이름이"'에'name' [자바 스크립트의 –
가능한 중복 속성이 hasOwnProperty에 포함되는 것 ?] (http://stackoverflow.com/questions/9396569/javascript-what-is-property-in-hasownproperty) –