Skip to content

Instantly share code, notes, and snippets.

@ciwolsey
Last active August 29, 2015 14:05
Show Gist options
  • Save ciwolsey/c1b4b065ed3652338cc2 to your computer and use it in GitHub Desktop.
Save ciwolsey/c1b4b065ed3652338cc2 to your computer and use it in GitHub Desktop.
var Car = {
init: function(){
this.engine = "on";
},
engineToggle: function(){
if (this.engine == "on") this.engine = "off";
if (this.engine == "off") this.engine = "on";
},
engineReportStatus: function(){
console.log(this.engine);
}
}
var ford = Object.create(Car);
ford.init();
ford.engineToggle();
ford.engineReportStatus(); // Reports its "on"
ford.engineToggle();
ford.engineReportStatus(); // Still reports "on"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment