Skip to content

Instantly share code, notes, and snippets.

@rshivkumar95
Last active July 4, 2019 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rshivkumar95/ce069cf9105a228f5236bcea6ab6bf00 to your computer and use it in GitHub Desktop.
Save rshivkumar95/ce069cf9105a228f5236bcea6ab6bf00 to your computer and use it in GitHub Desktop.
'new' keyword with constructor function
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