Defines a property on a given object.
Donate to NGO Julenka. Support Ukranians in need.
Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.
Reflect.defineProperty() is like
Object.defineProperty() but returns a Boolean.
the function itself
- is static on the
- is of type
the 1st parameter is the object on which to define a property
- fails if it is not an object
- accepts an object
- accepts an instance (of a class)
2nd parameter is the name of the property to be defined on the object (normally a string)
- works with a
- a number gets converted into a string
undefined also gets converted into a string (watch out!)
- it can be a symbol
value is part of the 3rd parameter, given as a property in an object
- contains the initial value of the property, as an object in the property
- can be of any type (even itself)
the return value of the function indicates wether the property was defined successfully
- when the property was created (which requires the 3rd parameter too!!!)
- no matter what the value of the property is (just the 3rd param has to exist as
- when a non-configurable property wants to be changed to configurable=true
- when the object we want to add a property to is frozen
The specification for this function.
The MDN docs for this function.
Announcement of this kata on twitter.