As Jaromanda pointed out, you cannot use the new polyfill syntax, but now you can easily get around some use cases new.target
Taking a look at new.target docs , you will see some examples that can be easily written using es5
from new.target
function Foo() {
if (!new.target) throw "Foo() must be called with new";
console.log("Foo instantiated with new");
}
Foo();
new Foo();
without
function Foo() {
if (!(this instanceof Foo)) throw "Foo() must be called with new";
console.log("Foo instantiated with new");
}
Foo();
new Foo();
from new.target
class A {
constructor() {
console.log(new.target.name);
}
}
class B extends A { constructor() { super(); } }
var a = new A();
var b = new B();
without
class A {
constructor() {
console.log(this.constructor.name);
}
}
class B extends A { constructor() { super(); } }
var a = new A();
var b = new B();
,