In every JavaScript tutorial that I have looked there is something mentioned about a property of an object. But why do they call it a property? e.g. constructor property, var a = function{this.b}
where b
is again called property. As far as I know properties have getter and/or setter, so those one should be called field, shouldn't they?
Some browser vendor have implemented getters/setters for JavaScript properties.
FF and Webkit has __defineGetter__
and __defineSetter__
implemented for DOM objects and get and set for Object's which is outside of the ECMA specification. However both and also IE 8+ has the Object.defineProperty
(from the ECMA specification). Read about it here
As for you original question, I would say that the reason it's called property in JavaScript is that it's a dynamic language and the basic markup uses only properties and local var's. Since everything is bound to a specific scope-hierarchy all you have is different tree-branches on each level. And Douglas Croockford named them properties :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With