Syntax

JavaScript Arrow Function Syntax

In JavaScript, arrow function: defines a short function expression — const add = (a, b) => a + b;

Quick Answer

Syntax
const add = (a, b) => a + b;
JavaScriptSyntax

Arrow Function

Code example
const add = (a, b) => a + b;

Defines a short function expression.

Learn More

How to arrow function in JavaScript

  1. Open your JavaScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

JavaScript Arrow Function Syntax

Use const add = (a, b) => a + b;.

Related Syntax References

Frequently asked questions

What is the JavaScript syntax for arrow function?

Use this pattern: const add = (a, b) => a + b;

Can I copy this JavaScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this JavaScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify