If the target is a function, then calling the target as a constructor using the new operator or the Reflect.construct() method will execute the construct trap.
The construct trap takes two parameters. The first parameter is the target object and the second parameter is an array, representing the arguments of the constructor call.
The construct trap must return an object, representing the newly created instance. Here is a code example that demonstrates how to use the construct trap:
const proxy = new Proxy(function(){}, { construct(target, arguments) { return {name: arguments[0]}; } }); const obj = new proxy("Eden"); console.log(obj.name); //Output "Eden"