JS- ES6 arrow function

blossom0417
1 min readSep 13, 2018

--

function timesTwo(params) {
return params * 2
}
var timesTwo = params => params * 2---------------------let mirror = value => value;// equivalent to:let mirror = function(value) {
return value;
};
----------------------
// ES5
var multiplyES5 = function(x, y) {
return x * y;
};

// ES6
const multiplyES6 = (x, y) => { return x * y };
//ES5
var docLogEs5 = function docLog() {
console.log(document);
};

//ES6
var docLogEs6 = () => { console.log(document); };
docLogEs6(); // #document... <html> ….

#reference

https://www.sitepoint.com/es6-arrow-functions-new-fat-concise-syntax-javascript/

--

--

No responses yet