3 ms·
> To successfully use an abstraction, you need to understand the problem the abstraction is trying to solve and also understand how the abstraction has solved t
by irrational 3y ago
> To successfully use an abstraction, you need to understand the problem the abstraction is trying to solve and also understand how the abstraction has solved the problem.
Not just abstractions, but just about everything we use. For example, why were arrow functions added to JavaScript? After all, everything you can do with arrow functions you could do previously without arrow functions. What was the problem that arrow functions were trying to solve and how do arrow functions solve that problem? I wish MDN was updated so that at the top of every page it first gave an overview of what problem this particular feature solves and how it solves it. Including how the problem used to be solved with "old" syntax and why this new syntax is preferable. And when it is not preferable.
- takinola 3y agoI thought arrow functions were just designed to reduce verbosity and make code easier to read. Is there another reason?
- AA-BA-94-2A-56 3y agoI could be wrong, but don’t JavaScript’s closures rely on arrow syntax?
- takinola 3y agoI'm pretty sure closures are available to any function regardless of how they are defined. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures https://developer.mozilla.org/en-US/docs/Web/JavaScript/Clos...
- irrational 3y agoNo, anything you can do with arrow functions can be done without them. Arrow functions are just a simpler way of writing code. For example, you can control "this" in non-arrow functions using tools like call, apply, and bind. It is just more verbose.
- seangrogg 3y agoYes, arrow functions have a different (and more intuitive) lexical `this` than their more verbose counterpart. It is subtly more than just a syntax sugar.
- takinola 3y agoHa, I finally figured out how "this" works and then they changed it with arrow functions.