Report whether an instance's prototype is the class prototype.
Acceptance criteria
- 1.#out should show true.
JavaScript Tutorial · JavaScript Classes
These 10 tasks go with the JavaScript Prototype Chain chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “Every object has a prototype, and lookups walk up the chain until they find a match.” .
1.Find the prototypeexercise · easy · 10 min
Report whether an instance's prototype is the class prototype.
Passes when: #out should show true.
2.List the own propertiesexercise · easy · 10 min · practice plan
Report the own keys of an instance that also has a method.
Passes when: #out should show name.
3.Tell own from inheritedexercise · easy · 10 min · practice plan
Report hasOwnProperty for a property and a method.
Passes when: #out should show true false.
4.Walk two links upexercise · easy · 10 min · practice plan
Call a method inherited from the grandparent class.
Passes when: #out should show breathing.
5.Shadow a prototype methodexercise · medium · 10 min · practice plan
Give one instance its own method and leave the other alone.
Passes when: #out should show just for a / generic.
6.Fix the method copied onto the instancebug fix · easy · 8 min
A method in the constructor becomes an own property of every instance.
Passes when: #out should show just name.
7.Fix hasOwnProperty used for a methodbug fix · easy · 8 min · practice plan
An inherited method is not an own property.
Passes when: #out should show true false.
8.Fix the broken chainbug fix · easy · 8 min · practice plan
The middle class does not extend, so the chain stops short.
Passes when: #out should show breathing.
9.Fix the prototype changed for everyonebug fix · easy · 8 min · practice plan
Assigning to the prototype affects every instance, not just one.
Passes when: #out should show just for a / generic.
10.Fix the prototype compared to the classbug fix · easy · 8 min · practice plan
An instance's prototype is the class prototype, not the class.
Passes when: #out should show true.
Between them these tasks cover Prototypes, hasOwnProperty and Lookup.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.