Quiz 16: Prototypes and Inheritance
Question 1
Shows
true?JavaScript
class Person { }
class Student { }
const s = new Student();
Object.setPrototypeOf(s, Student.prototype);
s instanceof Person;Question 2
Shows
true?JavaScript
class Person {
}
const p = { }
Object.setPrototypeOf(p, Person.prototype);
p instanceof Person;Question 3
Shows
true?JavaScript
class Person {
constructor(name) {
this.name = name;
}
isCool() { return this.name.length > 5 };
}
const p = new Person('Dierk');
p instanceof Person;Question 4
Shows
true?JavaScript
class Person { }
class Student { }
const s = new Student();
Object.setPrototypeOf(s, Person.prototype);
s instanceof Student;Question 5
Shows
true?JavaScript
class Person { }
class Student { }
const s = new Student();
Object.setPrototypeOf(Student.prototype, Person.prototype);
s instanceof Person;Question 6
Shows
true?JavaScript
class Person { }
class Student extends Person { }
const s = new Student();
s instanceof Person;Question 7
Shows
true?JavaScript
class Person {
}
const p = { };
Object.setPrototypeOf(p, Person.prototype);
p instanceof Person;Question 8
Shows
true?JavaScript
class Person { }
class Student extends Person { }
const s = new Student();
s instanceof Student;Question 9
Shows
true?JavaScript
class Person { }
class Student { }
const s = new Student();
Object.setPrototypeOf(Student, Person);
s instanceof Person;