JavaScript Reflect.construct() MethodThe static Reflect.construct() method allows to invoke a constructor with a variable number of arguments. It gives also the added option to specify a different prototype. SyntaxParametertarget: It is the target function to call. argumentsList: It is an array-like object specifying the arguments with which target should be called. newTarget: It is a constructor whose prototype should be used. See also the new.target operator. If newTarget is not present, it will treat as a target. ReturnThis method returns a new instance of the target (or newTarget if present), initialized by the target as a constructor with the given arguments. ExceptionsThis exception will throw a TypeError if target or newTarget are not constructors. Example 1Output: [1, 2, 3] [1, 2, 3] Example 2Output: 6 Example 3Output: 8 6 Next TopicJavaScript Reflect |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India