Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen ES6 Arrow Functions | Getting Started: ES6
Introduction to React
course content

Kursinhalt

Introduction to React

Introduction to React

1. Getting Started: ES6
2. Getting Started: JSX
3. React in Practice
4. React Components
5. Controlling Data & Content
6. Hooks
7. React Router

book
ES6 Arrow Functions

Arrow functions are a new addition to JavaScript that let us create inline functions without using the function and return keywords. They are simply a shorter syntax version of the normal JavaScript functions. JavaScript function:

1234
let myFunc = function () { return 1 + 6; } console.log(myFunc());
copy

ES6 function:

js

If the function has only one statement and returns a value, then we can remove the braces and the return keyword, hence the resultant code will be:

js

We can also pass arguments in the ES6 inline functions, using the syntax:

12
let myFunc = (a, b) => a + b console.log(myFunc(5, 4));
copy

Task

Create an inline function named threeProduct that takes in three numbers / arguments namely a, b, c, and returns the product of those numbers. Call the function inside a console.log function and pass 1, 2 and 9 as arguments.

question-icon

Fill in the gaps.

let threeProduct = ;
console.log(threeProduct
);
18

Click or drag`n`drop items and fill in the blanks

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 4

Fragen Sie AI

expand
ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

course content

Kursinhalt

Introduction to React

Introduction to React

1. Getting Started: ES6
2. Getting Started: JSX
3. React in Practice
4. React Components
5. Controlling Data & Content
6. Hooks
7. React Router

book
ES6 Arrow Functions

Arrow functions are a new addition to JavaScript that let us create inline functions without using the function and return keywords. They are simply a shorter syntax version of the normal JavaScript functions. JavaScript function:

1234
let myFunc = function () { return 1 + 6; } console.log(myFunc());
copy

ES6 function:

js

If the function has only one statement and returns a value, then we can remove the braces and the return keyword, hence the resultant code will be:

js

We can also pass arguments in the ES6 inline functions, using the syntax:

12
let myFunc = (a, b) => a + b console.log(myFunc(5, 4));
copy

Task

Create an inline function named threeProduct that takes in three numbers / arguments namely a, b, c, and returns the product of those numbers. Call the function inside a console.log function and pass 1, 2 and 9 as arguments.

question-icon

Fill in the gaps.

let threeProduct = ;
console.log(threeProduct
);
18

Click or drag`n`drop items and fill in the blanks

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 4
Wir sind enttäuscht, dass etwas schief gelaufen ist. Was ist passiert?
some-alt