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;
Which of the following is a correct way to define an object using an object literal?
A). var car = {make: 'Toyota', model: 'Corolla'};
B). var car = make: 'Toyota', model: 'Corolla';
C). var car = new Object(make: 'Toyota', model: 'Corolla');
D). var car = Object.create(make: 'Toyota', model: 'Corolla');
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);
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 define a method in a constructor function?
A). this.methodName = function() {}
B). this.methodName: function() {}
C). this.methodName = () {}
D). this.methodName: () {}
What is the output of car.start() if var car = {start: function() {console.log('Car started');}};?
A). Car
B). started
C). Car started
D). Error
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 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
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.
How do you define a constructor function for a Car object?
A). function Car(make, model, year) { this.make = make; this.model = model; this.year = year; }
B). Car(make, model, year) { this.make = make; this.model = model; this.year = year; }
C). function create Car(make, model, year) { this.make = make; this.model = model; this.year = year; }
D). function construct Car(make, model, year) { this.make = make; this.model = model; this.year = year; }