- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
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
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.
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
...when you iterate over it with the following loop (I am using descriptive variable names here):
...you will see three items logged to your JS console:
This is telling you that the properties in object
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.