Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JS Arrow fuction

Arrow functions, introduced in ES6, provide a more concise syntax for writing functions.

let myFunction = (a, b) => a * b;

Before Arrow:

hello = function() {
  return “Hello World!”;
}

With Arrow Function:

hello = () => {
  return “Hello World!”;
}

It gets even more concise! If the function has a single statement that returns a value, you can omit the curly braces and the return keyword.

Arrow Functions Return Value by Default:

hello = () => “Hello World!”;
Note: This only applies when the function has exactly one statement.

If your function has parameters, you pass them within the parentheses.