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
Read with Reflect.get
easy10 minRead a property using Reflect instead of dot notation.
- 2
Check with Reflect.has
easy10 minCheck a property exists using Reflect.
- 3
Forward a read inside a Proxy
easy10 minUse Reflect.get inside a get trap.
- 4
Check whether a write succeeded
easy10 minReport whether writing to a frozen object worked.
- 5
List own keys
medium10 minList an object's own property names with Reflect.
Find the bug(5)
- 1
Fix Reflect.get given the arguments in the wrong order
easy8 minThe target comes first and the key second.
- 2
Fix the trap that does not forward to Reflect
easy8 minReturning a hardcoded value ignores whatever the target actually holds.
- 3
Fix Reflect.set checked with the wrong result
easy8 minA successful write returns true, a refused one returns false.
- 4
Fix Object.keys used where symbols matter
easy8 minReflect.ownKeys includes symbol keys that Object.keys skips.
- 5
Fix deleteProperty never called
easy8 minThe 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