Considerar:
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
llamado en el body.onload
evento.
Esperaba shape1.hasOwnProperty(name)
devolver verdadero, pero está volviendo falso.
¿Cuál es el comportamiento correcto?
fuente
"name"
diferencia dename