Last active
January 26, 2017 19:19
-
-
Save jtsternberg/7d3c458a1db22dcde92c2f56ae62c546 to your computer and use it in GitHub Desktop.
Prototypal Inheritance: https://medium.freecodecamp.com/understanding-prototypal-inheritance-in-javascript-with-css-93b2fcda75e4#.d0a4x364q
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 Circle = { | |
radius : 0, | |
create : function(radius) { | |
// Creating prototypal linkage using Object.create | |
var obj = Object.create(this); | |
obj.radius = radius; | |
return obj; | |
}, | |
area : function() { | |
return Math.PI * this.radius * this.radius; | |
} | |
}; | |
var circle5 = Circle.create(5); | |
var circle10 = Circle.create(10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment