January 2020
Intermediate to advanced
548 pages
13h 36m
English
Static methods and properties can be declared by using the static keyword:
class Accounts { static allAccounts = []; static tallyAllAccounts() { // ... }}Accounts.tallyAllAccounts();Accounts.allAccounts; // => []
These properties and methods could also easily be added after the initial class definition:
Accounts.countAccounts = () => { return Accounts.allAccounts.length;};
Static methods are useful when you have a method or property whose functionality and existence are semantically related to the entire class as opposed to a singular instance.
Read now
Unlock full access