- Notifications
You must be signed in to change notification settings - Fork345
Open
Labels
Description
When we call barnaby and spot is the instance object value already set to true automatically even though our prototype is set to false? As I was tracing through trying to understand why the instance object would not be set to false as it inherits from the prototype as it doesn't make sense to me. If it was set to false than the first call would console.log Barnaby is already sitting but if it was true than it would skip this and console.log as show in the example. Scratching my head on this one.
// adding new property for sittingDog.prototype.sitting = false;// adding new method for sitDog.prototype.sit = function() { if (this.sitting) { console.log(this.name + " is already sitting"); } else { this.sitting = true; console.log(this.name + " is now sitting"); }};barnaby.sit();barnaby.sit();spot.sit();spot.sit();