Q
In JavaScript, what keyword is used to define a new object from a constructor function?

Answer & Solution

Answer: Option C
Solution:
The new keyword is used to create an instance of an object from a constructor function.
Related Questions on Average

What is the purpose of the this keyword in an object method?

A). It refers to the global object.

B). It refers to the current object.

C). It refers to the parent object.

D). It refers to the previous object.

What will car['make'] return if var car = {make: 'Ford', model: 'Mustang'};?

A). Ford

B). Mustang

C). Undefined

D). Error

How do you create a method inside an object using an object literal?

A). methodName: function() {}

B). methodName = function() {}

C). methodName: () {}

D). methodName: method() {}

What does Object.assign(target, ...sources) do?

A). Copies properties from sources to target

B). Compares properties between target and sources

C). Deletes properties in sources

D). Merges properties of sources into target and removes duplicates

Which of the following correctly creates an instance of a Car object using a constructor function?

A). var myCar = Car('Toyota', 'Corolla', 2020);

B). var myCar = new Car('Toyota', 'Corolla', 2020);

C). var myCar = create Car('Toyota', 'Corolla', 2020);

D). var myCar = construct Car('Toyota', 'Corolla', 2020);

Which of the following is the correct way to delete a property from an object?

A). remove object.property;

B). delete object.property;

C). delete object[property];

D). object.property = null;

How do you define a method inside a class in JavaScript ES6?

A). methodName() {}

B). this.methodName = function() {}

C). function methodName() {}

D). methodName: function() {}

What will the following code output? console.log(car.make); if var car = {make: 'Honda', model: 'Civic'};

A). Honda

B). Civic

C). Undefined

D). Error

How do you define a class in JavaScript ES6?

A). class ClassName { constructor() {} }

B). function ClassName() { constructor() {} }

C). class ClassName() { constructor {} }

D). function class ClassName { constructor() {} }

How do you add a new property to an existing object in JavaScript?

A). object.property = value;

B). object->property = value;

C). object:property = value;

D). object.addProperty('property', value);