class Person { constructor(name){ this.name = name }; sayHello(){ return Hi ${this.name} } } const person = new Person('Jon Doe');
Hi ${this.name}
console.log(person.sayHello()); //HI Jon Doe
You can also use the constructor function to create an object in es6.
Yeah... that's it, thank you
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
class Person {
constructor(name){
this.name = name
};
sayHello(){
return
Hi ${this.name}
}
}
const person = new Person('Jon Doe');
console.log(person.sayHello()); //HI Jon Doe
You can also use the constructor function to create an object in es6.
Yeah... that's it, thank you