In this blog we can see what are the Tuples in TypeScript.
Tuples in TypeScript :
Tuple is a new data type introduced by TypeScript. Tuples can have two different data types as values.
Tuples can be used in the same way as any other variable. They can be used as function call arguments.
Syntax :
var tuple_name = [value1,value2,value3,…value n]
Creating a Tuple :
To create a tuple, declare it as a variable and fill it with fields using the assignment operator (=).
Syntax :
var tuple_name = [feild1,feild2,…,feild n]
Example :
var Employee1 = [“Ajay”, 23, “crmonce”]
console.log(“Name of the Employee is : “+Employee1[0])
console.log(“Age of the Employee is : “+Employee1[1])
console.log(Employee1[0]+” is working in “+Employee1[2])
Output ;
Name of the Employee is : Ajay
Age of the Employee is : 23
Ajay is working in crmonce
For any Help or Queries Contact us on info@crmonce.com or +918096556344