Lesson 16. Destructuring parameters

After reading lesson 16, you will

  • Know how to destructure array parameters
  • Know how to destructure object parameters
  • Know how to simulate named parameters
  • Know how to create aliased parameters

In lesson 11 you learned about destructuring objects and arrays. These same principles can be used directly within the parameter list of a function. This makes array and object parameters easier to deal with and more self-documenting, and opens the door for useful techniques such as simulating named parameters.

Consider this

The following function takes three parameters. How would you go about making all of the parameters optional so the function could be called setting only the necessary values? For ...

Get Get Programming with JavaScript Next 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.