new.target
using new.target inside constructors
We'll cover the following...
After the introduction of new.target
for classes in ...
Press + to interact
function MyConstructor() {console.log( new.target === MyConstructor, typeof new.target );if ( typeof new.target === 'function' ) {console.log( new.target.name );}}new MyConstructor();//> true "function"//> MyConstructorMyConstructor();//> false "undefined"
Whenever ...