Comparison of programming languages (associative array): Difference between revisions

Content deleted Content added
JavaScript: copy editing
JavaScript: copy editing
Line 582:
In this example, the sallyNumber value will now contain the string "555-9999".
 
=====''Enumeration''=====
The keys in a map are ordered. Thus, when iterating overthrough it, a map object returns keys in order of insertion. The following demonstrates enumeration using a for-loop:
 
The keys in a map are ordered. Thus, when iterating over it, a map object returns keys in order of insertion. The following demonstrates enumeration using a for-loop:
 
<syntaxhighlight lang=JavaScript>
// loop through the collection and display each entry.
for(const [name, number] of phoneBook) {
console.log(`'Phone number for ${name} is ${number}`');
}
</syntaxhighlight>