Skip to content

Instantly share code, notes, and snippets.

@jtsternberg
Last active January 26, 2017 19:19
Show Gist options
  • Save jtsternberg/7d3c458a1db22dcde92c2f56ae62c546 to your computer and use it in GitHub Desktop.
Save jtsternberg/7d3c458a1db22dcde92c2f56ae62c546 to your computer and use it in GitHub Desktop.
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