How do you define a method in a constructor function?
A). this.methodName = function() {}
B). this.methodName: function() {}
C). this.methodName = () {}
D). this.methodName: () {}
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);
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
Which method can be used to call a function defined within an object?
A). object.functionName();
B). object->functionName();
C). object::functionName();
D). object.callFunction('functionName');
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; }
How do you create a method inside an object using an object literal?
A). methodName: function() {}
B). methodName = function() {}
C). methodName: () {}
D). methodName: method() {}
How can you iterate over all properties of an object?
A). for (var key of object)
B). for (var key in object)
C). for (var key with object)
D). for (var key over object)
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');
How can you check if a property exists in an object?
A). 'property' in object
B). object.hasProperty('property')
C). object.contains('property')
D). object.includes('property')
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.