Properties vs. Keys vs. Values in JavaScript

I'm trying to clarify my understanding of the terms "property" vs. "keys" vs. "values" in the JavaScript realm. After reading a few books on the language and even googling the terms, I still don't feel like I'm clear on their precise meaning. So suppose we have the following:

var object = ; 
Is my understanding of the following terms correct:
property refers to "name" key refers to "name" value refers to 5

I'm most concerned about "property": does it refer to identifiers only, or to the whole name/value pair?

asked Feb 21, 2015 at 16:26 7,267 4 4 gold badges 38 38 silver badges 71 71 bronze badges

You are correct. And also by property you mean key-value pair altogether, but you can refer to key only too.

Commented Feb 21, 2015 at 16:29

You say key when you are talking about maps . You say property or attribute when talking about an object . And off-course value should be pretty clear.

Commented Feb 21, 2015 at 16:30

The above comment is the best I have read and better than the 2 answers here so far. The thing about Javascript is that js objects and js arrays are pretty much the same thing, unlike most other languages.

Commented Feb 21, 2015 at 16:45

@2pha: objects are the same as associative arrays < >but not as a normal array [ ] . In javascript there is no separate concept for an associative array, hence it is an object.

Commented Feb 21, 2015 at 16:58 There is a clear separate concept. real arrays have functions specific to arrays Commented Feb 21, 2015 at 17:05

5 Answers 5

They don't have a precise meaning, especially "property" is ambiguous.

The term property (also: attribute, less common or even used for different things in JS) usually refers to the key/value pair that describes a member of an object. While, especially when used with a specific identifier (key), it often refers to the whole combination, it can also denote the value of that member. It does usually not mean the identifier itself.

When people try to be accurate, they distinguish between "property" (the whole thing, part of an object), "property name" (the string used as the key) and "property value" (the stored data).

answered Feb 21, 2015 at 17:12 658k 157 157 gold badges 1k 1k silver badges 1.4k 1.4k bronze badges Actually property is something different then attribute. Commented Jan 18, 2017 at 19:35

@MaxZoom As the linked Wikipedia article puts it, "the term attribute can and is often treated as equivalent to a property depending on the technology being discussed". In OOP they're synonymous, in JS DOM they're absolutely not.