Classes and Objects in JavaScript
A class is a set or category of things having some property or attribute in common i.e., car is a class having similar properties such as color, engine, gear, model number etc. The “class” construct allows us to define prototype-based classes. Syntax for declaring a class:
1 2 3 4 5 6 7 8 9 10 | class User { constructor(name) { this.name = name; } display() { alert(this.name); } } let user = new User("Sherlock"); user.display(); |
Objects Objects are the instance of classes i.e., … Read more