Q
What will console.log(car.make); output if var car = {make: 'Toyota', model: 'Corolla'};?

Answer & Solution

Answer: Option A
Solution:
The make property of the car object is Toyota, so it outputs Toyota.
Related Questions on Average

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 call a method from a parent class in a subclass in JavaScript ES6?

A). super.methodName()

B). this.methodName()

C). parent.methodName()

D). base.methodName()

How do you iterate over all properties of an object var person = {name: 'John', age: 30};?

A). for (var key in person)

B). for (var key of person)

C). forEach(key in person)

D). forEach(key of person)

How do you create an instance of the Car object using the constructor function?

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

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

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

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

How do you add a new property gender with value male to the person object?

A). person.gender = 'male';

B). person.gender = male;

C). person.gender = ['male'];

D). person[gender] = 'male';

What will console.log(newCar.make); output if class Car { constructor(make) { this.make = make; }} var newCar = new Car('Honda');?

A). Honda

B). Car

C). Undefined

D). Error

How do you access the value of the name property in the object var person = {name: 'John', age: 30};?

A). person['name']

B). person.name

C). person->name

D). person::name

What will the following code output? console.log(person['age']); if var person = {name: 'John'};

A). 30

B). John

C). undefined

D). null

What does Object.keys(person) return if var person = {name: 'John', age: 30};?

A). ['name', 'age']

B). ['John', 30]

C). {'name', 'age'}

D). {'John', 30}

How do you define a method named greet in an object var person = {};?

A). person.greet = function() {};

B). person.greet: function() {};

C). person.greet = () {};

D). person.greet = function {};