Skip to content

Commit 5797994

Browse files
committed
Edit Help
1 parent b514ed3 commit 5797994

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,34 @@ For each test you complete:
1919
See help with class construction, parameters, properties, and inheritence in
2020
[https://github.com/devleague/js-zombies/blob/master/doc/oop-example.pdf](/doc/oop-example.pdf)
2121

22+
When instructed to call the super class, use the `Function.prototype.call` method.
23+
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call
24+
25+
```
26+
// SUPER CLASS
27+
function Item(name) {
28+
this.name = name;
29+
}
30+
31+
// SUB CLASS
32+
function Weapon(name, damage) {
33+
this.damage = damage;
34+
Item.call(this, name); // Call super class
35+
}
36+
```
37+
38+
To extend the super class, use the `Object.create` method introduced in
39+
https://github.com/devleague/oop-factory-example
40+
41+
```
42+
// EXTEND SUPER CLASS
43+
Weapon.prototype = Object.create(Item.prototype, {
44+
constructor: {
45+
value: Item
46+
}
47+
});
48+
```
49+
2250
---
2351

2452
Item(name)

0 commit comments

Comments
 (0)