Quote from Parent website
"Prototype Properties"
"JavaScript objects inherit the properties of their prototype.
The delete keyword does not delete inherited properties, but if you delete a prototype property, it will affect all objects inherited from the prototype."
so why does the script below work?
<script>
function Person(first, last, age, eye) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
}
var myMother = new Person("Sally", "Rally", 48, "green");
delete myMother.age; // apparently... this should not work as "age" (as I understand) has been inherited from the Person prototype.
document.getElementById("demo").innerHTML =
"My father is " + myFather.age + ". My mother is " + myMother.age;
</script>
myMothe.age now outputs undefined and that's what i expected.
What am i misunderstanding?
Thank you in advance.