What is the class? =================== BLUEPRINT Logical entity Collection/group of data (attributes) and/or Methods (Behaviors). What is the object? =================== Physical Entity Instance/reference to the class. How to Create the class in JS? ============================== Keyword : class Syntax: class ClassName{ // class logic } // creation of class class Student{ constructor(stuName,stuId){ this.stuName = stuName; this.stuId = stuId; } } let/var/const ClassName = class(){ //logic of the class } // creation of class let Employee = class{ constructor(eid, ename, salary){ this.eid = eid; this.ename = ename; this.salary = salary; } } ========================================= How to Create the Object of the Class? ======================================= Syntax: let/var/const object-reference-name = new Class-Name-Constructor(values for constructor parameters with comma separation); // creation of class let Employee = class{ constructor(eid, ename, salary){ this.eid = eid; this.ename = ename; this.salary = salary; } } // object creation let employee1 = new Employee(122131,"Suresh",26000.0); let employee2 = new Employee(121213,"Keerthi",25500.0); console.log("The Employee1 Data = "); console.log("Employee Id = ",employee1.eid); console.log("Employee Name = ",employee1.ename); console.log("Employee Salary = ",employee1.salary); console.log("==========================="); console.log("The Employee2 Data = "); console.log("Employee Id = ",employee2.eid); console.log("Employee Name = ",employee2.ename); console.log("Employee Salary = ",employee2.salary); console.log("Employee Salary = ",employee1.salary); ============================================== How To Create The Method in the class? ====================================== class ClassName{ data members method-name(){ implementation } } class BankAccount{ constructor(accountNumber,balance){ this.accountNumber = accountNumber; this.balance = balance; } // method creation display(){ console.log("The User Banking Creddentials are:"); console.log("Account number = ",this.accountNumber); console.log("Balance = ",this.balance); } } const holder1 = new BankAccount(573602010007620, 28987.0); const holder2 = new BankAccount(19283746520,1029.0); holder1.display(); holder2.display(); ============================================================== class RandomClass{ constructor(){ this.a = 100; this.b = 200; } static p = 10; static q = 20; static sumData(){ console.log(this.p + this.q); } } let rc = new RandomClass(); // rc.sumData(); RandomClass.sumData(); // rc.sumData(); ============================================== If two static methods in the class with same name? ================================================== class myClass{ constructor(a){ this.a = a; } static display() { console.log("The Class variable = ",this.a); } static display() { console.log("Hello"); // console.log("The Local Variable = ",p); } } mc = new myClass(200); myClass.display(); // myClass.display(100); ===================================================== Q: If an Instance method and static method with same name? ========================================================== class myClass{ constructor(a){ this.a = a; } display() { console.log("The Class variable = ",this.a); } static display() { console.log("Hello"); // console.log("The Local Variable = ",p); } } mc = new myClass(200); mc.display(); myClass.display(); ================================================== If two instance methods in the class with same name? ===================================================== class myClass{ constructor(a){ this.a = a; } display() { console.log("The Class variable = ",this.a); } display() { console.log("Hello"); // console.log("The Local Variable = ",p); } } mc1 = new myClass(200); mc2 = new myClass(300); mc1.display(); mc2.display();