Skip to content

Instantly share code, notes, and snippets.

@rishisidhu
Created July 10, 2020 12:55
Show Gist options
  • Save rishisidhu/da94042c7c746142a9b20a50ce4ea9a0 to your computer and use it in GitHub Desktop.
Save rishisidhu/da94042c7c746142a9b20a50ce4ea9a0 to your computer and use it in GitHub Desktop.
Modern JS ES6+ features - Arrow Functions
//The old way of writing functions
var addf = function add(x, y) {
var sum = x + y;
return sum;
};
console.log(`The sum is : ${addf(10, 20)}`);
//The new way of writing functions
var newAdd = (x, y) => x + y;
console.log(`The sum is : ${newAdd(10, 20)}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment