Expressions and patterns

Class instance method

Try the free JavaScript compiler

An ordinary public instance method definition installs a non-enumerable function on the class prototype, shared by instances.

Formal Syntax & Structure

javascript syntaxjavascript
method(...args) { /* body */ }

Working Example

Example Snippetjavascript
class C{m(){return 1;}}console.log(new C().m===new C().m);
JavaScript Reference