Languages
[Edit]
EN

TypeScript - foreach loop

7 points
Created by:
Marcin
18610

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

 

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