📘Reflect

JSobjectbuilt-in ⟩ Reflect

A built-in object that provides methods for interceptable operations. The methods are the same as those of proxy handlers.

Reflect is not a function object, so it's not constructible

the first parameter to all the Reflect methods is called the target parameter.

Reflect.method()Triggers when…

apply(f, o, args)

  • invokes f as a method of o , just like o.f(args).

  • same as f.apply(o, args).

construct(C, args, newTarget)

  • invokes C as a constructor.

  • same as new C(...args).

  • newTarget is used as new.target (if specified).

defineProperty(o, key, desc)

  • delete a property.

  • similar to delete o[key].

  • returns boolean.

get(o, key, receiver)

  • get a property.

  • similar to o[key].

  • (not sure what the receiver is for. 😕)

has(o, key)

  • check if object o has property key.

  • similar to key in o.

  • returns true for any inherited properties.

set(o, key, value, receiver)

  • set a property.

  • similar to o[key] = value.

  • returns boolean.

  • (not sure what the receiver is for 😕)

Last updated