When working with JavaScript, it's interesting to note that creating a class with a static method allows you to call that method using the subclass name as well, since static methods are inherited.
The Object class, which serves as the superclass for all classes in JavaScript, offers many static methods. However, despite this widespread inheritance, none of those methods can be called using any subclass names.
Click here for more information on static methods within the Object class.
Some have suggested explicitly using 'extend' Object, but this seems unnecessary given that Object is already the implicit superclass for every class in JavaScript. This can be seen through examples like the .toString() method, which is present in every object from every class and is inherited from the Object class without needing to explicitly write 'extends Object'.
It's worth questioning why non-static methods are automatically inherited while static methods are not. Consider the following sample code:
class Test {
constructor() {}
}
const test = new Test();
console.log(test.toString()); // works, inherited from Object class
console.log(Test.<any static method of Object>)); // doesn't work