JavaScript: fields or properties

Every JavaScript tutorial that I looked at mentions something about the property of an object. But why do they call it property? For example, a constructor property, var a = function{this.b} where b again called a property. As far as I know, properties have a getter and / or setter, so they should be called a field, right?

+7
javascript properties field
source share
2 answers

Some browser vendors have implemented getter / setter methods for JavaScript properties.

FF and Webkit have __defineGetter__ and __defineSetter__ implemented for DOM objects, and get and set for an object that is outside of the ECMA specification. However, both, as well as IE 8+, have Object.defineProperty (from the ECMA specification). Read about it here.

As for your initial question, I would say that the reason he named the property in JavaScript is because it is a dynamic language, and the basic markup uses only properties and local variables. Since everything is associated with a specific hierarchy of scope, all you have is different branches of the tree at each level. And Douglas Crookford named their properties :)

+4
source share

This is similar to hash , map , dictionary and associative array ; different languages ​​like to call them different things. The terminology (unfortunately) is not 100% translated between programming languages.

+2
source share

All Articles