Created
August 17, 2015 00:46
-
-
Save goldhand/abdcdb2dc1ff0ca36991 to your computer and use it in GitHub Desktop.
Solution to this: https://gist.github.com/goldhand/ee3a60bdab87ccf7a52e
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
function Car() { // constructor | |
this.driverCount = 0; // this refers to the newly created object | |
} | |
Car.prototype.incrementDriverCount = function() { | |
// increments the driverCount of the instance of the new object invoking this method | |
this.driverCount++; // this still refers to the object who is invoking this function | |
return this.driverCount; | |
}; | |
var myCar = new Car(); | |
var myOtherCar = new Car(); | |
var myWeekendCar = new Car(); |
Author
goldhand
commented
Aug 19, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment