foreach ts code example
Example 1: javascript foreach
var colors = ['red', 'blue', 'green'];
colors.forEach(function(color) {
console.log(color);
});
Example 2: foreach typescript
example() {
for (let item of this.items) {
if (true) {
return;
}
}
// Do stuff in case forEach has not returned
}
Example 3: foreach typescript
for (let item of this.items) {
if (true) {
return;
}
}
Example 4: typescript foreach
let num = [7, 8, 9];
num.forEach(function (value) {
console.log(value);
});