class in javascript
What you will learn here about JavaScript
- class in javascript
class in javascript
class is nothing but the blue print or master copy. class has methods and instance variables. JavaScript uses class keyword to create a class in javascript.
example of creating class in javascript is given below
class sample
{
constructor()
{
this.number=10;
}
logger()
{
console.log(“we are in logger function”);
}
}
Creating object of class
In javascript object of class is created by using new keyword with constructor.
const obj=new sample();// object of class class is created
Method calling using object
const obj=new sample();
obj.logger();
obj.logger();