foreach loop in angular 8 code example
Example 1: foreach typescript
example() {
for (let item of this.items) {
if (true) {
return;
}
}
}
Example 2: typescript foreach
let num = [7, 8, 9];
num.forEach(function (value) {
console.log(value);
});
Example 3: foreach typescript
for (let item of this.items) {
if (true) {
return;
}
}
Example 4: angular for each
var values = {name: 'misko', gender: 'male'};
var log = [];
angular.forEach(values, function(value, key) {
this.push(key + ': ' + value);
}, log);
expect(log).toEqual(['name: misko', 'gender: male']);