Read a property using Reflect instead of dot notation.
Acceptance criteria
- 1.#out should show Ada.
JavaScript Tutorial · JavaScript Performance
These 10 tasks go with the JavaScript Reflect 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: “Reflect provides the same operations as a Proxy trap, as plain functions you can call directly.” .
1.Read with Reflect.getexercise · easy · 10 min
Read a property using Reflect instead of dot notation.
Passes when: #out should show Ada.
2.Check with Reflect.hasexercise · easy · 10 min · practice plan
Check a property exists using Reflect.
Passes when: #out should show true.
3.Forward a read inside a Proxyexercise · easy · 10 min · practice plan
Use Reflect.get inside a get trap.
Passes when: #out should show Ada.
4.Check whether a write succeededexercise · easy · 10 min · practice plan
Report whether writing to a frozen object worked.
Passes when: #out should show false.
5.List own keysexercise · medium · 10 min · practice plan
List an object's own property names with Reflect.
Passes when: #out should show name,age.
6.Fix Reflect.get given the arguments in the wrong orderbug fix · easy · 8 min
The target comes first and the key second.
Passes when: #out should show Ada.
7.Fix the trap that does not forward to Reflectbug fix · easy · 8 min · practice plan
Returning a hardcoded value ignores whatever the target actually holds.
Passes when: #out should show Grace.
8.Fix Reflect.set checked with the wrong resultbug fix · easy · 8 min · practice plan
A successful write returns true, a refused one returns false.
Passes when: #out should show refused.
9.Fix Object.keys used where symbols matterbug fix · easy · 8 min · practice plan
Reflect.ownKeys includes symbol keys that Object.keys skips.
Passes when: #out should show 1 own key.
10.Fix deleteProperty never calledbug fix · easy · 8 min · practice plan
The property is still there because nothing actually removed it.
Passes when: #out should show true.
Between them these tasks cover Reflect.get/set, Reflect.has and Forwarding in a Proxy.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.