|
|
|
|
|
by 52-6F-62
2998 days ago
|
|
I'm actually a fan of the class syntax, and use it regularly. >no need to even type function for methods However, to be fair, you can do this with object method shorthand now: const deepThought = {
theAnswer: 42,
tellTheAnswer() {
return `The answer to life, the universe, and everything is ${this.theAnswer}`;
},
};
deepThought.tellTheAnswer(); // => 'The answer to life, the universe, and everything is 42.'
Which is also quite elegant. I think they both have their places depending on the program. I think it depends on readability needs at the time, and whether an instance is better than just a container in that circumstance. |
|