Tip 20 | Simplify Looping with Arrow Functions |
In this tip, you’ll learn to cut out extraneous information with arrow functions.
In JavaScript, you see a lot of callback functions. Those are functions that are passed as a parameter to other functions. Most of the loops you’re about to learn depend on callbacks.
Like most pre-ES6 code, functions are wordy. You have to explicitly declare that you’re creating a function with the function keyword, add curly braces to signify the body, use return statements to end the function, and so on. It’s not unusual for the callback to be longer than the function you inject it into.
Arrow functions changed that and made writing functions simple and short. And learning about them now will make all the loops ...
Get Simplifying JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.