Map

ES6 introduces a few new ways to store data. Up until now we have had Objects and Arrays to store information. In ES6 we now have Map, WeakMap, Set and WeakSet. These Objects provide a new way to store data in a collection of either key value pairs, or collection of values.

Why new data structures

Most languages will have data structures that are purely for data; Ruby has Hashes, Python has Dictionaries. The goal of these structures is to create a simple data store. In JavaScript we have always used Objects to do this. Objects can be simple key value pairs, or include more features, such as methods.

However with Objects in JavaScript comes lots of added data that we might not want. When you create a simple object:

Get hands-on with 1200+ tech skills courses.