Arrow Functions

suggest change

An arrow function is a way of defining a function in ECMAScript 6. The snippets below are alternatives, not one program.

// traditional way of declaring and defining a function
var sum = function(a, b) {
    return a + b;
}
// Arrow function
let sum = (a, b) => a + b;

// Function definition using multiple lines
let checkIfEven = (a) => {
    if (a % 2 == 0)
        return true;
    else
        return false;
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents