Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.
An arrow function expression is a compact alternative to a traditional function expression, with some semantic differences and deliberate limitations in usage:
Rest parameters, default parameters, and destructuring within params are supported, and always require parentheses:
Arrow functions can be async by prefixing the expression with the async keyword.
Let's decompose a traditional anonymous function down to the simplest arrow function step-by-step. Each step along the way is a valid arrow function.
Note: Traditional function expressions and arrow functions have more differences than their syntax. We will introduce their behavior differences in more detail in the next few subsections.
In the example above, both the parentheses around the parameter and the braces around the function body may be omitted. However, they can only be omitted in certain cases.
The parentheses can only be omitted if the function has a single simple parameter. If it has multiple parameters, no parameters, or default, destructured, or rest parameters, the parentheses around the parameter list are required.
The braces can only be omitted if the function directly returns an expression. If the body has statements, the braces are required. In this case, return values must be explicitly specified with the return keyword. Arrow functions cannot guess what or when you want to return.
Arrow functions are not inherently associated with a name. If the arrow function needs to call itself, use a named function expression instead. You can also assign the arrow function to a variable, allowing you to refer to it through that variable.
Arrow functions can have either an expression body or the usual block body.
In an expression body, only a single expression is specified, which becomes the implicit return value. The block body is analogous to traditional function bodies, where return values must be explicitly specified with the return keyword. Arrow functions are not required to return a value. If execution of the block body reaches the end without encountering a return statement, the function returns undefined like other functions.
Returning object literals using the expression body syntax (params) => { object: literal } does not work as expected.
This is because JavaScript only sees the arrow function as having an expression body if the token following the arrow is not a left brace, so the code inside braces ({}) is parsed as a sequence of statements, where foo is a label, not a key in an object literal.
To fix this, wrap the object literal in parentheses:
Arrow function expressions should only be used for non-method functions because they do not have their own this. Let's see what happens when we try to use them as methods:
Another example involving Object.defineProperty():
Because a class's body has a this context, arrow functions as class fields close over the class's this context, and the this inside the arrow function's body will correctly point to the instance (or the class itself, for static fields). However, because it is a closure, not the function's own binding, the value of this will not change based on the execution context.
Arrow function properties are often said to be "auto-bound methods", because the equivalent with normal methods is:
Note: Class fields are defined on the instance, not on the prototype, so every instance creation would create a new function reference and allocate a new closure, potentially leading to more memory usage than a normal unbound method.
For similar reasons, the call(), apply(), and bind() methods are not useful when called on arrow functions, because arrow functions establish this based on the scope the arrow function is defined within, and the this value does not change based on how the function is invoked.
Arrow functions do not have their own arguments object. Thus, in this example, arguments is a reference to the arguments of the enclosing scope:
In most cases, using rest parameters is a good alternative to using an arguments object.
Arrow functions cannot be used as constructors and will throw an error when called with new. They also do not have a prototype property.
The yield keyword cannot be used in an arrow function's body (except when used within generator functions further nested within the arrow function). As a consequence, arrow functions cannot be used as generators.
An arrow function cannot contain a line break between its parameters and its arrow.
For the purpose of formatting, you may put the line break after the arrow or use parentheses/braces around the function body, as shown below. You can also put line breaks between parameters.
Although the arrow in an arrow function is not an operator, arrow functions have special parsing rules that interact differently with operator precedence compared to regular functions.
Because => has a lower precedence than most operators, parentheses are necessary to avoid callback || () being parsed as the arguments list of the arrow function.
The call(), apply(), and bind() methods work as expected with traditional functions, because we establish the scope for each of the methods:
With arrow functions, since our add function is essentially created on the globalThis (global) scope, it will assume this is the globalThis.
Perhaps the greatest benefit of using arrow functions is with methods like setTimeout() and EventTarget.prototype.addEventListener() that usually require some kind of closure, call(), apply(), or bind() to ensure that the function is executed in the proper scope.
With traditional function expressions, code like this does not work as expected:
With arrow functions, the this scope is more easily preserved:
| ECMAScript® 2027 Language Specification # sec-arrow-function-definitions |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Feb 21, 2026 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.