Created
October 13, 2018 02:53
-
-
Save santosh/9ca7b0c9f39503fdc0399d62073ed4d3 to your computer and use it in GitHub Desktop.
Constructor functions, aka Classes (in other langs)
This file contains hidden or 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 = function(maxSpeed, driver) { | |
this.maxSpeed = maxSpeed; | |
this.driver = driver; | |
this.drive = function(speed, time) { | |
console.log(speed, time); | |
}; | |
this.logDriver = function() { | |
console.log("driver name is " + this.driver); | |
}; | |
}; | |
var myCar = new Car(140, "Santosh"); | |
myCar.drive(50, 1); | |
myCar.logDriver(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment