Classes and Methods
Static Methods
Call a method on the class itself.
Static Methods
static_method.js
const amount = 8;
class Pricing {
static addFee(value) {
return value + 2;
}
}
const total = Pricing.addFee(amount);
console.log("amount=" + amount);
console.log("total=" + total);
static-method
A static method belongs to the class, not to one instance. Use it for helpers that do not need instance fields.