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

Popular posts from this blog

Primitive Data Types in java

let - Keyword in JavaScript (Block scope)

Coding Problem 4: Smallest window containing 0, 1 and 2 [GFG - Problem Solving]