Permalink
Browse files

Replace `.__proto__` with `Object.create()` in prototypal example.

  • Loading branch information...
1 parent 9fe23f8 commit e4141097476b19f5c1dcccfd069b3c297ddb31e4 @creationix committed Mar 29, 2012
Showing with 7 additions and 9 deletions.
  1. +7 −9 articles/object-graphs-2/prototypal.js
@@ -12,16 +12,14 @@ var Rectangle = {
}
};
//square
-var Square = {
- name: "Square",
- getArea: function getArea() {
- return this.width * this.width;
- },
- getPerimeter: function getPerimeter() {
- return this.width * 4;
- },
+var Square = Object.create(Rectangle);
+Square.name = "Square";
+Square.getArea = function getArea() {
+ return this.width * this.width;
+};
+Square.getPerimeter = function getPerimeter() {
+ return this.width * 4;
};
-Square.__proto__ = Rectangle;
//test
var rect = Object.create(Rectangle);
rect.width = 6;

0 comments on commit e414109

Please sign in to comment.