A static "method" is just a regular function that is attached to a class. This is useful when it belongs to that class semantically, and in extreme cases necessary in an inheritance hierarchy. The class name provides a visual namespace for accessing the function, e.g. Map.from does something different than Set.from.

However, you would only ever do that when you already have an existing class. You would never create an empty class only to put a static method inside it. In such a case, a simple object literal with a regular object method suffices:

const MyObject = {
  myFunction() {
    console.log('foo');
  },
};
MyObject.myFunction();
Answer from Bergi on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Classes › static
static - JavaScript - MDN Web Docs - Mozilla
The static keyword defines a static method or field for a class, or a static initialization block (see the link for more information about this usage). Static properties cannot be directly accessed on instances of the class. Instead, they're accessed on the class itself.
🌐
W3Schools
w3schools.com › js › js_class_static.asp
JavaScript Static Methods
JS Examples JS HTML DOM JS HTML ... Prep JS Bootcamp JS Certificate JS Reference ... Static class methods are defined on the class itself....
Discussions

oop - Why would you build a static function in Javascript when you can build a regular function? - Stack Overflow
I am new to learning objects and classes in Javascript. I was just wondering, why would you attach a static method to a class, like so: More on stackoverflow.com
🌐 stackoverflow.com
What are your thoughts on Static Methods?
There is an easy way out with JS/TS, Dart, etc. Just use a top-level function which you export as well. Java is different because everything must be inside some class. I guess static methods are kinda nice if you want to mirror some Java API or whatever. It makes porting code a bit easier. More on reddit.com
🌐 r/javascript
29
4
September 26, 2017
Static method in class is recognised as a function, but when called it returns undefined
To answer your question about what static methods actually look like without the syntactic sugar: class MyClass { method1() { // do stuff } static method2() { // do other stuff } } is equivalent to function MyClass() { } MyClass.prototype.method1 = function () { // do stuff }; MyClass.method2 = function () { // do other stuff }; More on reddit.com
🌐 r/learnjavascript
7
4
August 17, 2018
Concretely, what is the purpose of static method in es6 ?
It provides methods related to classes and class instances that don't necessarily require a class instance to be used. Note that these have existed before ES6. ES6 only added the static keyword used to create static methods when using the class syntax. A common use case is factory functions. These functions are used to create instances in ways contrary to normal construction. You can see these in JS builtins like: Array.from() Object.create(, ) Promise.resolve() Other, similar examples are utility functions that generate data relating to that type Number.parseInt(, ) Date.now() They can also be utilities for obtaining information about instances Array.isArray() Object.getOwnPropertyDescriptor(, ) Note that, as static methods, these operations can be run against values that may not be instances of that type. For example Array.isArray() wouldn't be very useful as an instance method only available to Array instances. More on reddit.com
🌐 r/javascript
6
3
August 22, 2018
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › js-static-methods
JavaScript Static Methods and Properties - GeeksforGeeks
JavaScript Static Methods and Properties are defined on a class itself rather than its instances, and are accessed using the class name.
Published   3 weeks ago
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › classes
Static properties and methods
May 3, 2022 - Static properties are used when we’d like to store class-level data, also not bound to an instance. ... MyClass.property = ... MyClass.method = ...
🌐
Scaler
scaler.com › home › topics › javascript › javascript static methods
JavaScript Static Methods - Scaler Topics
October 10, 2023 - A static method in JavaScript is a method that has a static keyword prepended to itself. Such methods cannot be accessed through instantiated objects but could be accessed through the class name.
🌐
Alma Better
almabetter.com › bytes › tutorials › javascript › static-methods-in-javascript
Static Methods In JavaScript
April 25, 2024 - A static method in JavaScript is a function that belongs to a class, but not to any particular instance of that class.
🌐
Medium
noncodersuccess.medium.com › mastering-javascript-static-methods-what-they-are-and-how-to-use-them-exploring-static-methods-d3e4c523fc1e
Mastering JavaScript Static Methods | What They Are and How to Use Them | Exploring Static Methods in JavaScript for Cleaner Code | by NonCoderSuccess | Medium
September 10, 2024 - To sum up, static methods in JavaScript offer a clean and efficient way to create class-level functionality that doesn’t depend on individual instances. By defining methods directly on the class, you can streamline your code, especially for utility functions or common operations that are shared across instances.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › static-methods-in-javascript
Static Methods in JavaScript - GeeksforGeeks
June 20, 2024 - JavaScript Static methods are defined directly on the classes, not on the instances of the class. Static methods can be of any name. A class can contain more than one static method.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Glossary › Static_method
Static method - Glossary - MDN Web Docs
A static method (or static function) is a method defined as a member of an object but is accessible directly from an API object's constructor, rather than from an object instance created via the constructor.
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript tutorial › javascript static methods
JavaScript Static Methods
October 6, 2023 - By definition, static methods are bound to a class, not the instances of that class. Therefore, static methods are useful for defining helper or utility methods. To define a static method before ES6, you add it directly to the constructor of ...
🌐
Reddit
reddit.com › r/javascript › what are your thoughts on static methods?
r/javascript on Reddit: What are your thoughts on Static Methods?
September 26, 2017 -

Does this apply to JavaScript?

Static methods usually indicate a method that doesn't know where it belongs. It is sitting out there trying to belong to the class it is on, but it doesn't really belong, because it doesn't use the internal state of the class. When we look at our classes from the Single Responsibility Principle (SRP) viewpoint, a static method is usually a violation because it tends to have a responsibility that is not the same of the class it is attached on.

Top answer
1 of 5
8
There is an easy way out with JS/TS, Dart, etc. Just use a top-level function which you export as well. Java is different because everything must be inside some class. I guess static methods are kinda nice if you want to mirror some Java API or whatever. It makes porting code a bit easier.
2 of 5
4
I use static methods for class simplification, and external inheritance. For a class simplification example, this is a piece of a vector class I wrote: export default class Vector { constructor({ x, y }) { this.x = x; this.y = y; } // ... a bunch of methods. static getZero() { return new this({ x: 0, y: 0 }); } static fromArray([x, y]) { return new this({ x, y }); } } Its far easier to call Vector.getZero() than to call new Vector({ x: 0, y: 0 }), or even to import a new file called createZeroVector() over an over. It makes more sense to keep the generation simplification of a class as a part of the class itself. This also allows you to extend and inherit these functions with much more ease. As for external inheritance, I don't know if there is a better way to do this, but I've also used static methods to achieve something like this: class Parent { constructor({ a, b }) { this.a = a; this.b = b; } static defaultOptions = { a: 0, b: 0, }; static create(options = {}) { return new this({ ...this.defaultOptions, ...options, }); } } class Child extends Parent { static defaultOptions = { a: 1, b: 2, }; } // child will have this.a === 1 and this.b === 2. const child = Child.create(); Which would let you easily create defaults for your class.
🌐
CodeWithHarry
codewithharry.com › tutorial › js-static-method
Static Method | JavaScript Tutorial | CodeWithHarry
In object-oriented programming, a static method is a method that is associated with a class, rather than an instance of the class. In JavaScript, static methods are defined using the static keyword and they can be accessed without creating an instance of the class.
🌐
TutorialsPoint
tutorialspoint.com › javascript › javascript_static_methods.htm
JavaScript - Static Methods
A static method in JavaScript is defined using the static keyword followed by the method name. You can execute the static method by taking the class name as a reference rather than an instance of the class.
🌐
Medium
medium.com › @anisurrahmanbup › javascript-static-method-details-c43f9733e34d
JavaScript Static Method (Details) | by Anis 💌 React20Bulletin | Medium
August 22, 2023 - Static methods are useful when you want to define a function that is related to a class, but does not need to access the instance properties or methods. They can also be used to create singleton patterns or factory functions.
🌐
GeeksforGeeks
geeksforgeeks.org › js-static-methods
JavaScript Static Methods | GeeksforGeeks
Static methods are functions that are defined on a class but are not accessible through instances of the class. Instead, they are called directly on the class itself.
Published   January 20, 2025
🌐
Educative
educative.io › answers › what-is-static-property-and-method-in-javascript
What is static property and method in JavaScript?
The static properties and methods are assigned to the class function instead of to the prototype of the class function. So, we cannot call the static method and properties using the instance of the class.
🌐
Medium
fab1o.medium.com › javascript-static-class-3e1acdaec81
JavaScript: static classes - Fabio Costa - Medium
February 3, 2023 - In other words, you cannot use the new operator to create a variable of the class type. A static class can be used as a convenient container for methods that just operate on input parameters and do not have to get or set any internal instance fields.
🌐
Medium
medium.com › @yyang0903 › static-objects-static-methods-in-es6-1c026dbb8bb1
Static Methods in ES6. Static methods, like many other… | by eechen | Medium
August 3, 2016 - Static methods, like many other features introduced in ES6, are meant to provide class-specific methods for object-oriented programming in Javascript. Static methods in Javascript are similar to class methods in Ruby.
🌐
Codefinity
codefinity.com › courses › v2 › 3ad37fbc-0d15-4d27-bee7-b107747da548 › 4314284f-a746-420c-8bac-022ec5837acc › d54ac916-4692-489e-a287-42226f76d2cb
Learn Using Static Methods in JavaScript | Mastering JavaScript Classes and Inheritance
Think of a utility company that provides electricity. The company itself (class) provides the power, but you (an instance) don't need to create a power plant at your home. Instead, you access the company's service (static method) directly.