ES6 reflect reflection mechanism

Time:2021-8-21

Reflect

handler

  • get
  • set
  • Has (similar to in, you can traverse the prototype chain)
  • apply
  • call
  • Defineproperty (define the property, possibly refine the property description)
  • deleteProperty
  • Isextensible (judge whether it can be expanded)
  • preventExtensions
  • Getprototypeof (read prototype object)
  • Setprototypeof (set prototype object)
  • Ownkeys (excluding prototype chain and attribute array)
  • Getownpropertydescriptor (obj, prop) [get object description]
  • construct
  • Symbol(Symbol.toStringTag): “Reflect”

Summary

It seems that both object and reflect have methods, but using reflect is more concise and can avoid the problem that the object object is a vacuum object without methods