Short answer
An arrow function is a compact function written with => instead of the function keyword. It does not get its own this, arguments, or super, so it is a poor method. Add the async keyword in front when you need an async arrow. Calling it with new throws a TypeError.
Last verified against the sources listed below.
Key takeaways
- Parentheses are optional only for one plain parameter. Zero, many, default, rest, and destructured parameters need them.
- Drop the braces only when the body is one expression. A block needs an explicit return.
- Wrap an object literal in parentheses, or the braces are read as a block and the function returns undefined.
- MDN says arrows have been widely available across browsers since September 2016.
- ECMA-262 says an arrow does not define local bindings for arguments, super, this, or new.target.
How to write arrow function in JavaScript starts with a parameter list, the token =>, and either one expression or a braced block.
MDN’s arrow function page calls this a compact alternative to a function expression, with different rules for this. The same page says the feature has been available across browsers since September 2016.
Can I use currently lists global usage at 97.4 percent, marks Chrome 45 and later as supported, and marks Internet Explorer 11 as not supported. Arrows are part of the language covered in what JavaScript is.
What you need
You need a JavaScript environment that supports arrows, which current browsers do, and a place to put the function.
That place can be a script file, a module, or a callback inside another function. You do not need a library. If you are pasting an icon into a component, the SVG to JSX converter turns the markup into a component. Any click handler you add around that component can be an arrow, with the limits below.
Ecma International’s publication page lists ECMA-262, 17th edition, June 2026, as the ECMAScript 2026 specification, and it points at the living draft on tc39.es. The draft section on arrow functions is the behavior to read when MDN and the spec disagree about a detail. They agree on the main limits.
Write the syntax
The shape is parameters, then =>, then a value or a block. Parentheses and braces are optional only in narrow cases.
MDN lists these forms: () => expression, param => expression, (param) => expression, and (param1, paramN) => expression. A block uses braces and, when you need a value, the return keyword. Parentheses may be omitted only when there is exactly one simple parameter. Zero parameters, several parameters, and default, rest, or destructured parameters all require parentheses.
A block without return returns undefined, the same as any other function that falls off the end. An expression body returns that expression and does not use the word return. This pair is enough to see both shapes, plus the async prefix MDN documents:
const double = (n) => n * 2;
const add = (a, b) => {
return a + b;
};
const load = async (url) => url;
double(3) returns 6, and add(1, 2) returns 3. load is an async arrow because async sits in front of the parameter list.
MDN shows the same prefix on a single parameter and on a parenthesized list. The page does not add a second meaning for async beyond that prefix.
Follow the numbered steps
Do one edit per step. Step 6 is only for an async function.
- Write the parameter list. Use parentheses unless there is exactly one plain parameter.
- Put
=>on the same line as that list. A line break before the arrow is a syntax error. - If the function returns one expression, write that expression and skip the braces.
- If the body has statements, wrap it in braces and add
returnwhen you need a value. - If the expression is an object literal, wrap the object in parentheses.
- If the function should be async, type
asyncbefore the parameter list.
Step 5 exists because { foo: 1 } after an arrow is parsed as a block, not as an object. MDN says () => { foo: 1 } returns undefined, and the fix is () => ({ foo: 1 }). Step 2 matches MDN’s rule that the arrow cannot sit on the next line after the parameters.
Remember that an arrow has no this of its own
An arrow does not get a new this, arguments, or super. It uses the bindings of the scope where it was written.
The ECMAScript draft says an arrow function does not define local bindings for arguments, super, this, or new.target. A reference to those names resolves in the enclosing environment. The draft also says the arrow is not turned into a method by MakeMethod, even if the body mentions super.
MDN draws the practical line: do not use an arrow as a method. In its sample, a method written with => logs the outer this, while a method written with method syntax logs the object.
call, apply, and bind do not retarget an arrow. MDN also says a class field that holds an arrow closes over the instance this, and that value stays put even if you pull the function off the object.
That field is created per instance, which MDN notes can cost more memory than a normal method on the prototype.
Calling an arrow with new throws a TypeError. The function has no prototype. yield is not allowed in the body, so the arrow cannot be a generator. Use a traditional function for those jobs.
Fix the usual mistakes
Most failures are a grammar slip or a this value that points at the wrong object.
| What you see | Why it happens | What to change |
|---|---|---|
SyntaxError on => |
A line break sits before the arrow | Move => onto the parameter line |
| undefined from an object return | Braces were read as a block | Wrap the object in parentheses |
| undefined from a block | The block has no return | Add return, or drop the braces |
| this is the outer scope | Arrows do not get their own this | Use a method when the call should set this |
| TypeError: not a constructor | new was used on an arrow | Use a function declaration or expression |
| The async keyword was ignored in your reading | async must be a prefix, not a suffix | Write async before the parameters |
Can I use describes the shorthand as lexical this binding. That matches the draft: this comes from the enclosing environment, not from the call. If a callback only needs the outer this, the arrow is the form MDN shows with setTimeout. If the function is a method that should track its receiver, write it as a method.
Frequently asked questions
Can you put a line break before the arrow?
No. MDN says a line break between the parameters and the arrow is a SyntaxError. The arrow has to stay on the same line as the parameter list. You may break the line after the arrow, wrap the body in parentheses, or use a block with return. Line breaks between parameters are allowed when the parameter list itself is wrapped in parentheses. This is a grammar rule, not a style preference, so a formatter that moves the arrow down will produce code that does not parse.
Do call, apply, and bind change this inside an arrow?
No. MDN says those methods are not useful on an arrow because this is fixed by the scope where the arrow was created. In MDN's sample, an arrow defined at global scope still reads the global value when call, apply, or bind is pointed at another object. A traditional function in the same sample does pick up the object you pass. If you need a this that follows the call, write a regular function. An arrow will not follow it.
Can an arrow function be a constructor or a generator?
It cannot be either. MDN says calling an arrow with new throws a TypeError, and the function has no prototype property. The yield keyword is also illegal in the arrow body, except inside a generator that is nested further inside. That means you cannot create the arrow as a generator function. Use a traditional function when you need new, or when you need yield. The arrow form is for a value you call, not for a type you construct.
What does an arrow return if the block has no return?
Undefined. MDN says a block body works like other function bodies: if execution reaches the end without a return statement, the result is undefined. An expression body is different, because that single expression is the return value and you do not write return. Mixing the two styles is a common slip. People omit return inside braces and then read undefined at the call site. Put return in the block, or remove the braces if the body is one expression.
Does an arrow have an arguments object?
No. MDN says an arrow has no arguments object of its own. If you mention arguments inside the arrow, you get the arguments object of the enclosing function, when there is one. The practical replacement is a rest parameter, which MDN shows as (...args) in the parameter list. Rest parameters require parentheses even when there is only one name before the dots. That list is a real array-like rest binding, not the old arguments object.
Sources
- Arrow function expressions · MDN, 2026
- ECMAScript Language Specification, Arrow Function Definitions · TC39, 2026
- ECMA-262 · Ecma International, 2026
- Arrow functions · Can I use, 2026