Skip to content

Commit 1fc01d0

Browse files
committed
prototypical inheritance
1 parent cbb4e58 commit 1fc01d0

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

OOP/prototypal-inheritance.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// prototypical inheritance refers to the ability to access object properties from another object.
2+
let person = {
3+
greet: function () {
4+
return `${this.name} is cool`;
5+
},
6+
};
7+
8+
let rakib = Object.create(person);
9+
rakib.name = "rakib";
10+
console.log(rakib.name);
11+
console.log(rakib.greet());
12+
13+
let writer = Object.create(person);
14+
writer.book = "Kill Me Heal Me";
15+
console.log(writer.book);

0 commit comments

Comments
 (0)