About Lesson
Static Methods
Static methods belong to the class itself, not instances. They are often used for utility functions.
Example: Static Method in MathUtility Class
JavaScript
class MathUtility {
static add(a, b) {
return a + b;
}
}
console.log(MathUtility.add(5, 3)); // Output: 8
Here, add is a static method that can be called directly on the MathUtility class without creating an instance.