Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript class

//class in es6 are just functional constructor.
class PersonES6{
  constructor(firstname,lastname,age){
    this.firstname= firstname;
    this.lastname=lastname;
    this.age=age
  }
  aboutPerson(){
  console.log(`My name is ${this.firstname} ${this.lastname} and I am ${this.age} years old`)
  }
}

const shirshakES6= new Person('Shirshak','Kandel',25)
shirshakES6.aboutPerson();
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #javascript #class
ADD COMMENT
Topic
Name
8+1 =