File tree Expand file tree Collapse file tree
25_Revision/19_oops_and_classes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,4 +36,6 @@ Array.prototype.tomar = ()=>{
3636
3737// now i can use the array self made method
3838vegetable . tomar ( ) // Tomar is a title of sujit
39- vegetablePrice . tomar ( ) // Error here because it is object but this method onle give to array
39+ /* vegetablePrice.tomar() // Error here because it is object but this method onle give to array */
40+
41+
Original file line number Diff line number Diff line change 1+ // inheritance
2+
3+ let carBasic = {
4+ start : true ,
5+ break : true ,
6+ seat : true ,
7+ }
8+
9+ let carDieselFuel = {
10+ fuel : "Diesel"
11+ }
12+
13+ let carPetrolFuel = {
14+ fuel : "Petrol"
15+ }
16+
17+ let carInsurence = {
18+ insurence : true
19+ }
20+
21+ // Now i want to carBasic Method and Fuel type method in below car because car have need for this so
22+ // it is old syntax __proto__
23+ let mercedesCar = {
24+ color : "Black" ,
25+ airBag : "4" ,
26+
27+ __proto__ : carBasic ,
28+ __proto__ : carDieselFuel
29+ }
30+
31+ let rangeRover = {
32+ color : "white" ,
33+ airBag : "4"
34+ }
35+
36+ rangeRover . __proto__ = carBasic
37+ rangeRover . __proto__ = carPetrolFuel
38+
39+ // modern syntax
40+ Object . setPrototypeOf ( rangeRover , carInsurence )
41+ Object . setPrototypeOf ( mercedesCar , carInsurence )
42+
43+
You can’t perform that action at this time.
0 commit comments