Loading topic
in, or calls a function, the JavaScript engine turns that syntax into a call to a small, fixed set of operations. The specification calls these operations internal methods. You can't call them by name. They are written in double square6 min readthis, and ES6 syntax such as arrow functions and template literals. You should also have the idea from the previous chapter that every operation on an object, such as reading a property,6 min readget and set traps are covered in detail in th6 min readReflect.get and Reflect.set to 6 min readget and set traps, and that you know each trap corresponds to an internal method such as [[Get]] or [[DefineOwnProperty]]. You should also be comfortable with property descriptors an6 min readget and set traps work, how Reflect.get and Reflect.set supply default behavior, and how getters, setters, and prototype-chain lookup behave on ordinary objects. Its subject is the last parameter of those traps, receiver, and why your forwarding co6 min readget and set, and forwarding through Reflect with the correct receiver. This chapter covers three other traps that control whether a property seems to exist:5 min read[[Call]] runs when you call a function, and [[Construct]] runs when you use new. A proxy around a function can intercept both, through the apply and construct traps.5 min readget, set, has, deleteProperty, and ownKeys traps cover the operations most code uses every day. Six more traps handle the lower-level operations: defining properties, reading property descriptors, reading and changing the prototype, and controlling extensibility. You will reach for the5 min readget trap could make up values, a has trap could hide keys, and an ownKeys trap could filter enumeration. That freedom has limits. After most traps return, the engine checks the result against the target, and it throws a5 min readnew Proxy(target, handler), how traps forward to the target with Reflect, and what proxy invariants are. A revocable proxy is a normal proxy with an off switch. Until you flip the switch, it behaves exactly like any other proxy. On6 min readget, set, has, deleteProperty, ownKeys, and defineProperty traps, how to forward each one with the matching Reflect method, and why the receiver arg6 min readget, set, has, ownKeys, apply, and the rest. Some JavaScript behavior does not go through those operations. When code depends on that behavior, a pr6 min read