Languages
[Edit]
EN

TypeScript - create array

0 points
Created by:
Vanessa-Drake
718

This article will show you how to create an array in TypeScript.

Quick solution:

 

Practical examples

Edit

Output:

The above creation of an array can also be written as follows:

Output:

or:

Output:

Note: this approach will cause automatic array resizing on assigning new indexes - by assigning non consecutive indexes, the array will be filled in unused areas with null values.

or:

Output:

Note: this approach allocates necessary array space during array creation - not necessary resize in memory later.

or:

Output:

Note: the constructor-based approach used a much less frequent approach.

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