Languages
[Edit]
EN

TypeScript - foreach loop

7 points
Created by:
Imaan-Morin
889

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

 

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

TypeScript

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join