add function on foreach typescript code example
Example 1: foreach typescript
example() {
for (let item of this.items) {
if (true) {
return;
}
}
// Do stuff in case forEach has not returned
}
Example 2: foreach typescript
for (let item of this.items) {
if (true) {
return;
}
}
Example 3: foreach javascript
var items = ["item1", "item2", "item3"]
var copie = [];
items.forEach(function(item){
copie.push(item);
});
Example 4: javascript foreach syntax
const marks = [12, 17, 14];
let sum = 0;
marks.forEach(mark => {
sum += mark;
});