Defining a Method

Dive into the basics of class methods and learn the power and perils of class methods in JavaScript.

Methods are an integral part of classes. They exhibit behavior and are often used to perform some action, or possibly to effect state change.

Syntax

To define a method, place the function body within the {} of the class definition—but without the function keyword.

svg viewer

Get hands-on with 1400+ tech skills courses.