EN
TypeScript - foreach loop
7
points
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