This is the code for Pet
:
function Pet() {
this.vitals = new Vitals();
}
function Vitals() {
this.hunger = 5;
this.thirst = 0;
this.emotions = {
happy: true,
sad: true
}
}
Below is the calling and so forth:
$(document).ready(function () {
var pet = new Pet();
console.log(pet);
pet.vitals.emotions.happy = false;
console.log(pet);
});
This is what I get from the console:
Question: Why is happy
false
in both readouts, and not just the second one?