Skip to content

Commit 818acec

Browse files
committed
Property Lookup
1 parent 1cda28d commit 818acec

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

app.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
/*
2-
Prototypal Inheritance Model
3-
Javascript uses prototypal inheritance model. That means that every constructor function/class has a prototype property that is shared by every instance of the constructor/class. So any properties and methods or prototype can be acessed by every instance. prototype property returns a object
2+
Property Lookup
3+
If child does not have ask parent
4+
Everything in JS is an Object
45
*/
56

67
function Account(name, initialBalance) {
78
this.name = name;
89
this.balance = initialBalance;
10+
this.bank = "Bank Of America";
11+
//This takes precedence over proto, if not present then it will look property and methods in proto
912
}
1013

1114
Account.prototype.bank = "CHASE";
@@ -17,8 +20,11 @@ Account.prototype.deposit = function (amount) {
1720
const john = new Account("john", 200);
1821
const bob = new Account("bob", 400);
1922

20-
john.deposit(300);
21-
bob.deposit(1000);
23+
// john.deposit(300);
24+
// bob.deposit(1000);
2225

2326
console.log(john);
2427
console.log(bob.bank);
28+
29+
console.log({});
30+
console.log([]);

0 commit comments

Comments
 (0)