Example of Static Methods in JavaScript

Feature thumb js video thumb

Static methods in JavaScript aren't not as common to see as traditional instance methods. If you're unfamiliar with the difference, the dead simple explanation is below:

Instance methods can only be called on an instance of the class, in other words, you need to first instantiate the class, typically saving it to a variable, and then you can call instance methods on that... instance. Static methods can only be called directly on the class itself, so they don't care about the object that you create with the class, they simply are helper methods.

Still clear as mud? Let's look at some examples that should help clarify the key differences.