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 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; }
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
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 create a method inside an object using an object literal?
A). methodName: function() {}
B). methodName = function() {}
C). methodName: () {}
D). methodName: method() {}
In JavaScript, what keyword is used to define a new object from a constructor function?
A). create
B). construct
C). new
D). object
What will car['make'] return if var car = {make: 'Ford', model: 'Mustang'};?
A). Ford
B). Mustang
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 does Object.keys(obj) return?
A). An array of the values of the object's properties
B). An array of the names of the object's properties
C). The first key of the object
D). The number of properties in the object
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