The method function

Methods can be any function, they could take arguments, maybe they won't take arguments, and to define them all we do is the following. Without adding a comma, another quirk of the class syntax, we specify our method name. I'm going to create one called getUserDescription:

getUserDescription () {}

This one is not going to take any arguments so we can leave that arguments list empty. Inside the function itself, we're going to go ahead and return a description, since the method after all is called getUserDescription. We're going to return a template string injecting some values inside there, the general flow is going to be Jen is 1 year(s) old:

getUserDescription () {  return `Jen is 1 year(s) old`;}

This is what we want ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.