For in loop - typescript full explanation
For..in the loop is used for iterating on array in typescript. For..in loop return the index of array elements.this loop can be used with Array,List,Tupel
Syntax:
for(let index in <some array>){
//statements
}
For Example :
let person = ["SAM","BOM","BOB","NIL"]
for(let index in person){
console.log("index"+index); // this will print index
console.log("name : " + person[index] ); // this will print array's value.
}
Comments
Post a Comment