javascript Classes and Inheritance

 JavaScript Classes and Inheritance 

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Document</title>
</head>

<body>
    <script>
        class Employee {
            constructor(name, experience, division) {
                this.Ename = name;
                this.Eexperience = experience;
                this.Edivision = division;
            }
            slogan() {
                return `i am ${this.Ename} and this company is best`;
            }

            joiningYear() {
                return 2021 - this.Eexperience;
            }

            static add(a,b){
                return a + b;
            }
        }


        obj1 = new Employee("shreyash", 21, 'A');
        console.log(obj1);
        console.log(obj1.slogan());
        console.log(obj1.joiningYear());
        console.log(Employee.add(2,4))

    </script>
</body>

</html>
Output
Employee {Ename: 'shreyash', Eexperience: 21, Edivision: 'A'}
 i am shreyash and this company is best
 2000
 6
Inheritance

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Document</title>
</head>

<body>
    <script>
        class Employee {
            constructor(name, experience, division) {
                this.Ename = name;
                this.Eexperience = experience;
                this.Edivision = division;
            }
            slogan() {
                return `i am ${this.Ename} and this company is best`;
            }

            joiningYear() {
                return 2021 - this.Eexperience;
            }

            static add(a, b) {
                return a + b;
            }
        }

        class Programmer extends Employee {
            constructor(name, experience, division, languege, github) {
                super(name, experience, division);
                this.Elanguege = languege;
                this.Egithub = github;
            }
            favLanguege() {
                if (this.languege == 'python') {
                    return 'python'
                } else {
                    return 'javascript'
                }
            }
            static multiply(a, b) {
                return a * b;
            }
        }

        rohan = new Programmer('Rohan', 3, "A", "java", "rohan420");
        console.log(rohan);
        console.log(Programmer.multiply(4, 3));
        console.log(rohan.Egithub);
        console.log(rohan.favLanguege());
    </script>
</body>

</html>
Output
Programmer {Ename: 'Rohan', Eexperience: 3, Edivision: 'A', Elanguege: 'java', Egithub: 'rohan420'}
 12
 rohan420
javascript