My background in mathematics is very poor (i.e. last relevant math class taken was high school Trigonometry two years ago - another story for another time). I'm reading 'Javascript: The Definitive Guide' and it's a term that is being repetitively used and I've sort of just ran with it. But I've come to a chapter (Chapter 6 - Objects) where my lack of understanding of the term and its application in programming/OOP is starting to become detrimental to the learning process. The online dictionaries aren't helping out, so does somebody have a more explainable definition and/or example to show?


Mathematically, enumerable means "can be placed into a one to one correspondence with the natural numbers". Most representations in computing are enumerable because they are made of strings of bits, and strings of bits can be taken to denote numbers in the binary system.

Some data representations are not considered enumerable, though. For instance a floating point number is made out of bits, but we work with it as an approximation to a real number. At the binary level we can "count" through consecutive floating-point numbers, but usually this is not relevant in numeric applications.

In some other situations, enumeration is possible, but there is no agreement on an enumeration. For instance, all the objects in your run-time image constitute a finite set and can be enumerated. The garbage collector does that that when it walks through the live objects. But the application does not enumerate the set of all objects in that way without regard for type or module boundaries; it enumerates smaller of objects that are of the same kind, or related.

Usually where an enumeration exists formally, there is agreement by all parties. Here is a set of values. This one is first. That one is its successor, and so on.

In some programming languages, there exist enumerated types: some disciplined way of defining named symbolic constants which are mapped by the compiler to unique integer values. If such types are strongly typed, then these constants can only be stored in variables of their corresponding type, called an enumerated type. For instance a user-defined enumeration of type month can only take on the values january through december. These are reduced to the values 0 through 11, and may allow arithmetic, such as successor(january) producing february, or the possibility of using the enumeration as an array index: defining an array days[january..december] where days[january] is, say, 31. The purpose of an enumerated type, therefore, is to serve as a subset of the natural numbers, by other names that are distinct and provide clarity of meaning (names are used instead of numeric constants) and type checking: the color red from a color enumeration cannot be assigned to a month type enumeration.

The verb enumerate is also used to denote the concept of querying an API to retrieve a list of objects, usually in stepwise fashion: enumerate the network interfaces, enumerate the files in a directory, and so on. Whenever an object is in a 1:N correspondence with some other objects, it it is susceptible to supporting an enumeration API which lets us walk through those sibling objects, or retrieve them as a list. The terminology is a little murky; for instance in some cases, even if the elements are not in a particular order, but can all be visited without repetition, it is still enumeration. Some dynamic set data structures such as hash tables do not provide a particular order, and can reorganize themselves as they grown and shrink, so that the actual order varies when insertions and deletions are performed. A can come before B, but when we insert C, now B happens to come before A because some internal reorganization took place.


I just pulled out my copy of JavaScript: The Definitive Guide, flipped to chapter 6, and quickly read over the section 6.5 Enumeratng Properties. Now, I should add that I'm not a particularly strong math person either, so hopefully this makes sense:

Specifically, "enumerable" means that there is some sort of ordering scheme taking place, so that you can quickly/easily address the items in that set/sequence/collection (or, in that section of JavaScript: The Definitive Guide, the object).

To apply it to what you are reading in the book, when the author says that the properties you extend a class with are enumerable, he is merely saying, that any property you add to an object (not those that are inherited) can be iterated over. So, if you create an object obj like so:

var obj = {a: 1, b: 2, c: 3};

...when you iterate over it with the following loop (I am using descriptive variable names here):

for (prop in obj) {

...you will see three items logged to your JS console:

  • a
  • b
  • c

This is telling you that the properties in object obj, are enumerated by the keys a, b, and c.

  • 1
    So in that example, a, b, c are enumerable properties? And alternatively, an unenumerable property is a property that is not enumerated by keys?
    – gr33kbo1
    May 28 '13 at 1:09
  • 2
    Exactly. In the case of JavaScript, any properties of an object that are not inherited from the base object are enumerable. If it helps, maybe try and think of an enumerable property as a property whose accessor you can recieve, when iterating over its parent object with a for-in loop.
    – nesv
    May 28 '13 at 15:38

An enumerable is an object that may be enumerated. "Enumerated" means to count off the members of a set/collection/category one by one (usually in order, usually by name).

An enumerable then is an object that can step through a series of other objects one by one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.