re: ES6 Arrow Functions Cheatsheet VIEW POST


I feel like all optional symbols must be eradicated.
I'm just on the fence with returning someone else's undefined or even worse another return when you don't want a return.

as.forEach(x => map.set(,a.value)) // Oh no, I am returning the map instance!
as.forEach(x => console.log(x)) // Oh no, I am returning `console.log`'s `undefined`

For the longest time, I would avoid that, adding a {}, especially if this is an otherwise available function.

const addToMap = x => { map.set(,a.value) }
const log = x => { console.log(x) }

as.forEach(addToMap) // Ahh, bliss

But then, on one cursed day, I once again stumbled upon ES6 tail call optimization spec. (Unlike most ES6, it is implemented ONLY in Safari & Mobile Safari, was REMOVED from Chrome, and is not in active development anywhere else.)

So, what is a tail call for that spec? Why, it's a function call the result of which is then returned, unconditionally. So you see my problem.
I have never had a night of good sleep since, and I am sure you can relate, since it would mean that functions like

const addToMap = x => map.set(,a.value)
const log = x => console.log(x)

With the return value discarded as late as possible, are superior.

time to die

code of conduct - report abuse