Starlit Daily

📚 › JavaScript: make pages do things

8. Arrow functions

ستتم ترجمة هذا المقال تلقائيًا. يُعرض بالإنجليزية حاليًا.

An arrow function is a short way to write a function: (a, b) => a + b. With one expression, the return is implied.

Arrow functions are common in modern code, for example inside forEach and map.

عرض المثال

const add = (a, b) => a + b;
console.log(add(2, 3));

✍️ دورك الآن

Write an arrow function square that returns n times n, then print square(7).

← العودة إلى الدورة