Deep understanding of object.defineproperty () method

1. What is object.defineproperty ()

 See documentation: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty

 Definition: The Object.defineProperty() method directly defines a new attribute on an object, or modifies an existing attribute of an object, and returns this object. (Note: Object This method should be called directly on the  constructor object, not on an Object instance of any  type.)

 语法:Object.defineProperty(obj, prop, descriptor)

Parameters: 
obj: the object whose property is to be defined (on which object is defined)
prop: the name of the property to be defined or modified or  Symbol (which property of this object to be defined)
descriptor: the property descriptor to be defined or modified ( What the attribute to be defined refers to)

Guess you like

Origin www.cnblogs.com/kymming/p/12706406.html