Arrow functions, introduced in ES6, provide a more concise syntax for writing functions.
let myFunction = (a, b) => a * b; |
hello = function() { return “Hello World!”; } |
hello = () => { return “Hello World!”; } |
It gets even more concise! If the function has a single statement that returns a value, you can omit the curly braces and the return keyword.
hello = () => “Hello World!”; |
Note: This only applies when the function has exactly one statement. |
If your function has parameters, you pass them within the parentheses.