How do you define a method inside a class in JavaScript ES6?
A). methodName() {}
B). this.methodName = function() {}
C). function methodName() {}
D). methodName: function() {}
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 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')
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);
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');
What is encapsulation in the context of JavaScript objects?
A). Hiding the internal state and requiring all interaction to be performed through an object's methods
B). Extending one object from another
C). Creating a new object
D). Removing a property from an object
How do you define a method in a constructor function?
A). this.methodName = function() {}
B). this.methodName: function() {}
C). this.methodName = () {}
D). this.methodName: () {}
In JavaScript, what keyword is used to define a new object from a constructor function?
A). create
B). construct
C). new
D). object