Last active
July 4, 2019 07:29
-
-
Save rshivkumar95/ce069cf9105a228f5236bcea6ab6bf00 to your computer and use it in GitHub Desktop.
'new' keyword with constructor function
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 Circle(radius) { | |
this.radius = radius; | |
this.draw = function() { | |
console.log(this.radius); | |
} | |
} | |
function Rectangle(radius) { | |
Circle.call(this, radius); | |
} | |
var c = new Circle(4); | |
c.draw(); | |
new Rectangle(12).draw(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment