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() {} }
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}
What is the output of console.log(person.greet()); if var person = {greet: function() {return 'Hello';}};?
A). Hello
B). Undefined
C). Error
D). Hello
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 inherit properties and methods from another class in JavaScript ES6?
A). class SubClass extends SuperClass {}
B). class SubClass inherits SuperClass {}
C). class SubClass implements SuperClass {}
D). class SubClass super SuperClass {}
What will console.log(car.make); output if var car = {make: 'Toyota', model: 'Corolla'};?
A). Toyota
B). Corolla
C). Undefined
D). Error
How do you define a constructor function for creating Car objects?
A). function Car(make, model) { this.make = make; this.model = model; }
B). Car(make, model) { this.make = make; this.model = model; }
C). var Car = function(make, model) { this.make = make; this.model = model; };
D). Car = function(make, model) { this.make = make; this.model = model; };
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 {};
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 can you delete the age property from the person object?
A). delete person.age;
B). remove person.age;
C). person.age = null;
D). person.age.delete;