foreachtypescriptbreakes5-shim

How to stop a forEach loop in Typescript - can I use .some()?


I've seen this question about stopping a ES5 forEach loop, which pretty much suggests to use .every() or .some() instead of forEach.

I believe I remember typescript uses shims for old browsers to support for example forEach. Is this correct and if so, can I use .some and .every just as well with the same kind of support as forEach?


Solution

  • I believe I remember typescript uses shims for old browsers to support for example forEach. Is this correct

    No. TypeScript has no runtime additions for shimming the compilied JavaScript (beyond the __extends function).

    can I use .some and .every just as well with the same kind of support as forEach?

    Here is the compatability table : http://kangax.github.io/compat-table/es5/#Array.prototype.some that you need to check for your browser.