Languages
[Edit]
EN

TypeScript - foreach loop

7 points
Created by:
Marcin
15710

In TypeScript it is possible to use foreach in following ways.

1. foreach syntax example

let array = [ 1, 2, 3, 'text' ];

for(let entry of array)
    console.log(entry);

Output:

1
2
3
text

2. forEach method example

let array = [ 1, 2, 3, 'text' ];

array.forEach((entry : any, index : number) : void => {
    console.log(entry);
});

Output:

1
2
3
text

 

Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join