Question · JavaScript and TypeScript course · Module 2: Functions, Arrays and Objects
Object Basics - Constructor with new
What does the 'new' keyword do before calling a constructor function?
Answer options
- Creates a copy of an existing object
- Creates a new global variable
- Imports a new module
- Creates a new empty object and sets 'this' to that object
Show the answer
Correct answer:
- Creates a new empty object and sets 'this' to that object