Browsers implement custom elements as native classes (separate from JS classes).
Some tooling insists on compiling down to ES5 and using Reflect.construct() instead of new makes it possible to use custom elements from ES5 code (obviously the browser has to support custom elements which implies that it also supports classes (ES2015)).
First time I came across
Reflect
was in the web components native shim:MDN:
Reflect.construct()
.Browsers implement custom elements as native classes (separate from JS classes).
Some tooling insists on compiling down to ES5 and using
Reflect.construct()
instead ofnew
makes it possible to use custom elements from ES5 code (obviously the browser has to support custom elements which implies that it also supports classes (ES2015)).a good one 👍