Languages
[Edit]
EN

TypeScript - add element to array

0 points
Created by:
Brandy-Mccabe
724

In this article, we would like to show you how to add an element to an array in TypeScript.

1. Add element at the end of array

Edit

To add an element at the end of an array we use push() method.

Runnable example:

Output:

2. Add element at the beginning of array

Edit

To add an element at the beginning of an array we use .unshift() method.

Runnable example:

Output:

Alternative titles

  1. TypeScript - add element at the end of array
  2. TypeScript - add element at the beginning of array
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