Ask Your Question
0

What is the method for defining a Fixed length Array in TypeScript?

asked 2023-02-13 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-06-24 22:00:00 +0000

pufferfish gravatar image

To define a fixed length array in TypeScript, you can use the following syntax:

let myArray: Array<number> = new Array<number>(5);

This creates an array of type number with a fixed length of 5. You can then access and manipulate the elements of the array as usual, but you cannot add or remove elements beyond the initial length.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-02-13 11:00:00 +0000

Seen: 14 times

Last updated: Jun 24 '22