Skip to main content

JavaScript Reflect — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Reflect 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

    Read with Reflect.get

    easy10 min

    Read a property using Reflect instead of dot notation.

  2. 2

    Check with Reflect.has

    easy10 min

    Check a property exists using Reflect.

  3. 3

    Forward a read inside a Proxy

    easy10 min

    Use Reflect.get inside a get trap.

  4. 4

    Check whether a write succeeded

    easy10 min

    Report whether writing to a frozen object worked.

  5. 5

    List own keys

    medium10 min

    List an object's own property names with Reflect.

Find the bug(5)

  1. 1

    Fix Reflect.get given the arguments in the wrong order

    easy8 min

    The target comes first and the key second.

  2. 2

    Fix the trap that does not forward to Reflect

    easy8 min

    Returning a hardcoded value ignores whatever the target actually holds.

  3. 3

    Fix Reflect.set checked with the wrong result

    easy8 min

    A successful write returns true, a refused one returns false.

  4. 4

    Fix Object.keys used where symbols matter

    easy8 min

    Reflect.ownKeys includes symbol keys that Object.keys skips.

  5. 5

    Fix deleteProperty never called

    easy8 min

    The property is still there because nothing actually removed it.

Ready to write the code?

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

Open the workspace