Answers for "Initialize a class definition javascript"

0

Initialize a class definition javascript

// Initializing a class definition
class Hero {
    constructor(name, level) {
        this.name = name;
        this.level = level;
    }
  	
  	 // Adding a method to the constructor
    greet() {
        return `${this.name} says hello.`;
    }
}
Posted by: Guest on March-18-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language