What does the keyword "new" do in JavaScript?

  • Creates a class
  • Declares a variable
  • Instantiates an object
  • Defines a function
The keyword "new" in JavaScript is used to instantiate an object from a class constructor. When you use "new" followed by a class constructor, it creates a new instance of that class, allowing you to work with objects that have the properties and methods defined in the class. It doesn't create a class, declare a variable, or define a function.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *