Search code examples
angulartypescriptinternet-explorercross-browserpolyfills

Angular 6: what is the Reflect API in polyfills.ts?


In polyfills.ts, one of the commented out lines reads as follows:

/** IE10 and IE11 requires the following for the Reflect API. */
// import 'core-js/es6/reflect';

What is the 'Reflect API'? What IE use cases is it needed for and is this import statement typically important when running an Angular application in IE? Surprisingly, Google and StackOverflow didn't turn up many/any results for me.


Solution

  • The ES6 Reflect API gives you a Reflect object that lets you call methods, construct objects, getting and setting prototypes, manipulating and extending properties. Reflect is a built-in object that provides methods for interceptable JavaScript operations. The methods are the same as those of proxy handlers. More details, please check the Reflect and the ES6 Reflect API Tutorial

    From the Browser compatibilitySection, we can see IE not support Reflect, by using the Polyfills, it makes us using Reflect in IE browser.