Skip to content

Commit 57975d5

Browse files
authored
Merge pull request chuanxshi#138 from AlexJeng/master
Fixed spacing for better consistency
2 parents 72c800b + 138aa98 commit 57975d5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎code-reuse-patterns/prototypal-inheritance.html‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,33 @@
3939
Person.prototype.getName=function(){
4040
returnthis.name;
4141
};
42+
4243
// create a new person
4344
varpapa=newPerson();
45+
4446
// inherit
4547
varkid=object(papa);
48+
4649
// test that both the own property
4750
// and the prototype property were inherited
4851
console.log(kid.getName());// "Adam"
4952

50-
5153
// parent constructor
5254
functionPerson(){
5355
// an "own" property
5456
this.name="Adam";
5557
}
58+
5659
// a property added to the prototype
5760
Person.prototype.getName=function(){
5861
returnthis.name;
5962
};
63+
6064
// inherit
6165
varkid=object(Person.prototype);
6266
console.log(typeofkid.getName);// "function", because it was in the prototype
6367
console.log(typeofkid.name);// "undefined", because only the prototype was inherited
6468

65-
6669
/* Addition to ECMAScript 5 */
6770
varchild=Object.create(parent);
6871

0 commit comments

Comments
(0)