Based on my tests, both of the below work awesomely with cloud functions
class Hero {
constructor(name, level) {
this.name = name;
this.level = level;
}
// Adding a method to the constructor
greet() {
return `${this.name} says hello.`;
}
}
and
unction Hero(name, level) {
this.name = name;
this.level = level;
}
// Adding a method to the constructor
Hero.prototype.greet = function() {
return `${this.name} says hello.`;
}
references:
https://www.digitalocean.com/community/tutorials/understanding-classes-in-javascript#classes-are-functions
class Hero {
constructor(name, level) {
this.name = name;
this.level = level;
}
// Adding a method to the constructor
greet() {
return `${this.name} says hello.`;
}
}
and
unction Hero(name, level) {
this.name = name;
this.level = level;
}
// Adding a method to the constructor
Hero.prototype.greet = function() {
return `${this.name} says hello.`;
}
references:
https://www.digitalocean.com/community/tutorials/understanding-classes-in-javascript#classes-are-functions
No comments:
Post a Comment