TypeScript #9: Tuples in TypeScript and uses with examples

Опубликовано: 31 Май 2025
на канале: Codehelp by Sahil
78
5

In this video lets discuss one more important point related to arrays, As in js arrays are pretty flexible and allows usage of multiple datatypes like in js u can declare an array let me declare one let multiarr which can hold values of multiple types like number string and boolean without any type declaration .
So if I have an array in js it can hold a string a number and a boolean as well. And we often have use cases in our applications when we need to manage such kind of data.

Now if we want the same thing in typescript as well to allow use of multiple types in the same array and not bound our array with a single type like let arr of type number or boolean but rather it could store a fixed set of types then how can we do that
Fo that we have a feature in typescript which is called as tuple which allows us to create an entity which is like an array which can hold values of a fixed set of datatypes.