foreach angular 8 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: typescript foreach

let num = [7, 8, 9];
num.forEach(function (value) {
  console.log(value);
});

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']);