Skip to content

Commit

Permalink
Day 43: Inheritance and Prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
uttu-316 committed Nov 29, 2022
1 parent f987430 commit 134c224
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions javascript/Day43/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
class Parent {
constructor() {
this.skinColor = "brown";
this.eyeColor = "black";
this.language = "hindi";
this.religion = "Hindu";
}
getReligion() {
return this.religion;
}
}

class Child extends Parent {
constructor(name, age, gender) {
super();
this.name = name;
this.age = age;
this.gender = gender;
}
}

const c = new Child("Sai", 23, "M");

const p = new Parent();

console.log(c.getReligion());

class CompanyDetails {
constructor() {
this.companyName = "Hindustan Uniliver Pvt. Ltd.";
//20 more properties
}
}

class Shampoo extends CompanyDetails {}

class Soap extends CompanyDetails {}

class Oil extends CompanyDetails {}

class A {
constructor() {
this.a = "A";
}
}
class B extends A {
constructor() {
super();
this.b = "B";
}
}
class C extends B {
constructor() {
super();
this.c = "C";
}
}

const c = new C();
const b = new B();

console.log(c, b);

obj.__proto__.__proto__.__proto__.__proto__.__proto__;

class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
}

class Doctor extends Person {
constructor(...args) {
super(...args);
this.profession = "Doctor";
}
}

const d = new Doctor("Sunidhi", 21);
console.log(d);

0 comments on commit 134c224

Please sign in to comment.