I really enjoyed this time and like others was using arrow functions everywhere. But 5 years later I started to hate arrow functions used as normal functions.
Code with one-liner functions and other variables:
const getData = dataKey => get(state, dataKey);
const makePlainObj = () => ({});
const doSth = ({ a, b }) => {console.log(b)};
const abc = { get: someFn };
const makePlainObj = () => ({});
const doSth = ({ a, b }) => {console.log(b)};
const abc = { get: someFn };
Code with normal functions:
function getData(dataKey) {
return get(state, dataKey);
}
function makePlainObj() {
return {};
}
function doSth({ a, b }) {
console.log(b);
}
const abc = { get: someFn };
return get(state, dataKey);
}
function makePlainObj() {
return {};
}
function doSth({ a, b }) {
console.log(b);
}
const abc = { get: someFn };
Yes, second code is longer but at the same time much more readable. On first look it is visible what is a variable and what is a function. Also functions are hoisted when created as variables arrow functions are not.