So consider you have a one line auto return arrow function:
const test = (val) => val;
How would you check the val
without doing:
const test = (val) => {
console.log(val);
return val;
};
You can actually use ||
between the arrow function and the returned value like so:
const test = (val) => console.log(val) || val;
This will not interfere with the process and will also log val
without the hassle of adding {}
and return
and undoing it once you're done