JavaScript Example (Program)
Learn Details

Example of multiple class inheritance

इस example में हमलोग एक class object के property की value को दूसरे class object के property की value को set करना सिखेंगे


1. Example of class & method with static value



<script>    
    
    //   ================ Office =======================
    //        1.  Mahesh Nayak = Manager
    //        2.  Sunder Lal   = Teeam Leader 
  

   // ==== 1.DEPARTMENT (IT Dept) ====          ==== 2.DEPARTMENT (Sales Dept)  ====      
    //  1. Ramesh Bhardwaj = Manager        1. Manoj Bajpai = Sales Manager
    //  2. Kunal Kapoor =  Team Leader        2. Ankita Thakur = Team Leader
    //  3. Lovely Singh = Designer          3. Anurag Gupta = Sales person
    //  4. Kumud Dikshit = Developer        4. Mamta Neghi  = Sales person
  

  
    class Office{
      constructor(officeManager, OfficeTl){
        this.myofficeManager =  officeManager;
        this.myOfficeTl = OfficeTl;
      }
      office_method(){
        return (`
          <p>Hello, I am <strong>${this.myofficeManager}</strong> and i am Manager

<p>Hello, I am <strong>${this.myOfficeTl}</strong> and i Team Leader

`) } } let myOffice = new Office("Mahesh Nayak", "Sunder Lal"); document.write(`<h3>This is Office Data</h3> ${myOffice.office_method()}`) //IT Dept class ItDept extends Office{ constructor(officeManager, OfficeTl, designerit, develoverit){ super(officeManager, OfficeTl); this.mydesigner = designerit; this.mydeveloper = develoverit; } ItDept_method(){ return (`${super.office_method()} <p>Hello, I am <strong>${this.mydesigner}</strong> and i am Designer

<p>Hello, I am <strong>${this.mydeveloper}</strong> and i am Developer

`) } } let myItDept = new ItDept("Ramesh Bhardwaj", "Kunal Kapoor", "Lovely Singh" , "Kumud Dikshit"); document.write(`<h3>This is IT Data</h3> ${myItDept.ItDept_method()}`) //Sales class salesDept extends Office{ constructor(officeManager, OfficeTl, sales_person1, sales_person2){ super(officeManager, OfficeTl); this.mysales1 = sales_person1; this.mysales2 = sales_person2; } salses_method(){ return (`${super.office_method()} <p>Hello, I am <strong>${this.mysales1}</strong> and i am Sales person

<p>Hello, I am <strong>${this.mysales2}</strong> and i am Sales person

`) } } let mysales = new salesDept("Manoj Bajpai", "Ankita Thakur", "Anurag Gupta", "Mamta Neghi"); document.write(`<h3>This is Sales Data</h3> ${mysales.salses_method()}`) </script>