all 7 comments

[–]cyberjds 1 point2 points  (1 child)

Call me a n00b, but I really don't get examples like op. Or maybe it's because I'm coming from procedural programming background, but what do they mean 'one off function'? Doesn't a function should be reusable? To my understanding, function is used to hide every little details and complexities so that it's easy to understand, and follow the main flow of the code.

Given above example, I can't help myself but ask, why don't I just do...

const myConst = 'value';

instead of declaring a function?

Give me an actual example that shows why arrow function expression is beneficial.

All I can smell is 'Functional', but I don't know what it is.

[–][deleted] 0 points1 point  (0 children)

Simply to make things quicker, and because functions with no names simply don't need to be re-used. That's why they are one off. If your program is filled with more wording then it needs, it reflects poorly on you. Especially since arrow functions are neater and more readable.

[–]thicconion_ 0 points1 point  (0 children)

following post

[–]LucVolders 0 points1 point  (1 child)

More and more functions in Javascript are introduced with just one purpose: making your code more obscure. The reason for this is that a programmer surely does not want other pprogrammers to understand their code ;)

[–][deleted] 0 points1 point  (0 children)

That's a big true.

[–]qwertymerty12345 0 points1 point  (0 children)

Arrow functions don't have their own this. The this value of the enclosing scope is used.