Reputation: 9
i read about defineProperty()
.
but i found this notation in a program i don't understand:
myObject.defineProperty("something", "propertyNameExample", function()
{
// function body here
})
what i do not understand is that function() {...}
notation.
what role does it play for "propertyNameExample"?
please explain me. thank you
Upvotes: 0
Views: 42
Reputation: 68393
Nothing (or technically not sure), this is not a native method for defining a property in Javsacript.
There are two things wrong here
Object.defineProperty
not myObject.defineProperty
myObject.defineProperty
will be a user defined function not a native function.As per documentation, third argument is a descriptor object not a function
.
Even if you pass a function as the parameter, it doesn't affect the functionality in any way, whether you are setting a property or getting a property.
Upvotes: 1