Languages
[Edit]
EN

TypeScript - replace many elements in array

0 points
Created by:
Mahir-Bright
1281

In TypeScript it is not intuitive at first time how to replace many elements in array. Replace operation can be achieved with Array.prototype.splice method. This article is focused on how to do it.

1. Replace many elements with Array.prototype.splice method example

Edit

Output:

Notes about Array.prototype.splice method:

  • takes as first argument index of begining of removed elements
  • takes as second argument number of removed elements
  • takes as third and next arguments added elements

Refrences

Edit
  1. Array.prototype.splice method - MDN Docs 

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