Reflect.construct(target, argumentsList)creates a new object from a constructor, just like new target(...argumentsList). The difference is that it is a normal function call, and the arguments come as an array.
An optional third argument, newTarget, lets you choose which constructor the new object should belong to. In everyday code you will mostly use the two-argument form.
Remember
Reflect.construct(target, argumentsList, newTarget)
target → a constructor (class or function)
argumentsList → an array of arguments
newTarget → optional: who the object is an instance of
same as: new target(...argumentsList)
arrow functions are not constructors
Syntax
Pass a constructor and an array of arguments. The result is a new object.
// ECMAScript 2015 (ES6)
Reflect.construct(target, argumentsList)
Reflect.construct(target, argumentsList, newTarget)
// target : a constructor
// argumentsList : an array-like object
// newTarget : optional constructor
// returns : the new object
// throws : TypeError if target or newTarget is not a constructor
Parameters
Parameter
Description
target
Required. The constructor to run, such as a class, a function, or a built-in like Map. Arrow functions and methods are not constructors and throw a TypeError.
argumentsList
Required. An array, or an array-like object, with the arguments for the constructor. Use [] for none.
newTarget
Optional. A constructor that decides the prototype of the new object and what new.target is. It defaults to target.
Return Value
Return Value
Description
Object
The new object that the constructor created. Its prototype comes from newTarget (or from target if you did not pass one).
TypeError (thrown)
target or newTarget is not a constructor, or argumentsList is not an object.
JavaScript Examples
Example 1 — Create an Object from a Class
Create a Point object with Reflect.construct() and check that it is a real instance.
kind: B
Instance of B: true
Instance of A: false
Arrow function: TypeError
How It Works
A different newTarget. The constructor of A runs, but new.target inside it is B, so kind is "B".
The prototype follows newTarget. The object gets the prototype of B, so it is an instance of B and not of A.
Not a constructor. An arrow function cannot be used with new, so Reflect.construct() throws a TypeError for it as well.
Compatibility
Browser & Runtime Support
Reflect.construct() is part of ES2015 (ES6), together with the Reflect object. Every current browser and Node.js has it.
✓ ES2015 · Widely supported
Reflect.construct()
Supported in Chrome 49+, Edge 12+, Firefox 42+, Safari 10+, Opera 36+ and Node.js 6+. Internet Explorer never got it.
ES2015Standard since
Google Chrome49+ · Desktop & Mobile
Full support
Microsoft Edge12+ · Chromium and legacy
Full support
Mozilla Firefox42+ · Desktop & Mobile
Full support
Apple Safari10+ · macOS & iOS
Full support
Opera36+ · Chromium based
Full support
Samsung InternetRecent versions · Android
Supported
Android WebView49+ · Chromium based
Supported
Node.js6+ · Server runtime
Supported
DenoSupported · JavaScript runtime
Supported
BunSupported · JavaScript runtime
Supported
Internet ExplorerNo native support
Not supported
Reflect.construct()Excellent
Bottom line: Safe to use in every current browser and in Node.js. The only thing to plan for is Internet Explorer, which has no Reflect at all.
Frequently Asked Questions
It creates a new object from a constructor, like the new keyword, but as a function call. The arguments are passed as an array, and you can optionally choose the newTarget.
new Point(1, 2) is a special syntax. Reflect.construct(Point, [1, 2]) is a normal function, so you can pass it around, build the argument list in code, and also set newTarget. For simple cases, new is shorter.
It decides which constructor the new object belongs to. The target constructor still runs, but the object gets the prototype of newTarget, and new.target inside the constructor is newTarget. Libraries use it for subclassing and in Proxy traps.
Only constructors: classes, regular functions and built-ins like Array, Map or Error. Arrow functions and object methods are not constructors, so they throw a TypeError.
A Proxy can intercept new with a construct trap. Inside the trap, Reflect.construct(target, args, newTarget) creates the object in the normal way, so you can add logging or checks around it.