Languages
[Edit]
EN

TypeScript - array destructuring with rest parameter

0 points
Created by:
James-Z
767

In this article, we would like to show you how to destructure arrays with the rest parameter in TypeScript.

In the below examples we use:

  • destructuring assignment syntax that allows us to extract data from arrays or objects into separate variables,
  • trailing commas (or final commas) - which are also allowed on the left-hand side while using the destructuring assignment.

1. Array destructuring

Edit

Simple destructuring example:

Using rest operator: 

Using trailing commas:

Trailing commas & rest operator:

2. Object destructuring

Edit

Simple destructuring:

Using rest operator: 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join