Arrow Functions
suggest changeAn 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;
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents