Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Class-level functions are functions that don’t require an instance of the class in order to be called. These functions can be incredibly useful. One of the best uses is to provide a sort of namespacing for your functions. An example of this in JavaScript is Math.random(). You don’t need to instantiate a new Math object to get a random number. But by hanging the random function off of the Math class, you avoid the risk that there is another function called random that might override your function.
In reality, Math isn’t a class; it’s just a plain object that is used for namespacing. Occasionally I twist the truth a little bit to help get my point across.
You can also use class-level functions to do things that might affect multiple instances of a class, like search for them in a database.