Answers for "typescript this inside foreach"

6

foreach typescript

example() {
    for (let item of this.items) {
        if (true) {
            return;
        }
    }
    // Do stuff in case forEach has not returned
}
Posted by: Guest on March-16-2020
0

foreach access this

data.forEach(function(d) {
    console.log(d);
    console.log(this.value);
  }, this);
  // ^^^^
Posted by: Guest on December-02-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language