9/28/2018 - 12:01 AM

Arrow Functions

Examples of different arrow functions

var func1 = () => console.log('func1'); // no arguments syntax
var func2 = param => console.log(param); // 1 arugment, no parenthases needed
var func3 = (param1, param2) => {console.log(param1 + param2);} //can also use brackets for the return

const race = '100m Dash';
const winners = ['Hunter Gath', 'Singa Song', 'Imda Bos'];

// The parentheses around the object literal are used to do an implicit return
const win =, i) => ({name: winner, race, place: i + 1}));

// When you use an arrow function, the value of `this` is not rebound inside of that function.
// It is inherited from whatever the parent scope is.