Skip to main content

JavaScript Prototype Chain — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Prototype Chain lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.

Exercises(5)

  1. 1

    Find the prototype

    easy10 min

    Report whether an instance's prototype is the class prototype.

  2. 2

    List the own properties

    easy10 min

    Report the own keys of an instance that also has a method.

  3. 3

    Tell own from inherited

    easy10 min

    Report hasOwnProperty for a property and a method.

  4. 4

    Walk two links up

    easy10 min

    Call a method inherited from the grandparent class.

  5. 5

    Shadow a prototype method

    medium10 min

    Give one instance its own method and leave the other alone.

Find the bug(5)

  1. 1

    Fix the method copied onto the instance

    easy8 min

    A method in the constructor becomes an own property of every instance.

  2. 2

    Fix hasOwnProperty used for a method

    easy8 min

    An inherited method is not an own property.

  3. 3

    Fix the broken chain

    easy8 min

    The middle class does not extend, so the chain stops short.

  4. 4

    Fix the prototype changed for everyone

    easy8 min

    Assigning to the prototype affects every instance, not just one.

  5. 5

    Fix the prototype compared to the class

    easy8 min

    An instance's prototype is the class prototype, not the class.

Ready to write the code?

The editor, the automatic checks and the worked solutions open up with an account.

Open the workspace