Arrow functions
ES6 introduced a new way to define anonymous functions using arrow (=>) operator. In this lesson, we learn how arrow operator helps us in writing more concise code.
Functions can be created in much more pleasant way in es6 with help of arrow functions
:
Press + to interact
const sum = (a, b) => {return a + b}
Or even in one line - no need in {}
and return
if we have single return statement in function body:
Press + to interact
const sum = (a, b) => a + b
and if we have one argument we even ...
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy