EN
TypeScript - foreach loop
7 points
In TypeScript it is possible to use foreach in following ways.
xxxxxxxxxx
1
let array = [ 1, 2, 3, 'text' ];
2
3
for(let entry of array)
4
console.log(entry);
Output:
xxxxxxxxxx
1
1
2
2
3
3
4
text
xxxxxxxxxx
1
let array = [ 1, 2, 3, 'text' ];
2
3
array.forEach((entry : any, index : number) : void => {
4
console.log(entry);
5
});
Output:
xxxxxxxxxx
1
1
2
2
3
3
4
text