Open In App

Difference between Tuple & Interface in TypeScript

Last Updated : 26 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Tuples and Interfaces in TypeScript are used for different purposes and they also have different characteristics. Some of the differences between tuples and interfaces are written below.

Tuple

Interface

It is an ordered collection of elements with different data types.

It is used to define the structure of an object in TypeScript

The elements stored in a tuple can accessed using their indexes just like arrays.

The properties of an interface can be accessed either using the dot notation or square brackets.

The number of elements stored in a tuple are fixed and their types are defined at the time of their definition.

They can be used to enhance the code reusability by extending their uses with classes or other interfaces.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads