Last active
August 29, 2015 14:05
-
-
Save ciwolsey/c1b4b065ed3652338cc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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