typeof returns object:
// Returns object: typeof fruits; |
instanceof Map returns true:
// Returns true: fruits instanceof Map; |
Differences between JavaScript Objects and Maps:
Object |
Map |
Not directly iterable. |
Iterable directly. |
Lack a size property. |
Contain a size property. |
Keys must be strings or symbols. |
Keys can be of any data type. |
Keys are not guaranteed to be ordered. |
Keys are ordered based on their insertion. |
Have predefined keys. |
Do not have predefined keys. |
Map is an ES6 feature (JavaScript 2015), and ES6 has been fully supported in all modern browsers since June 2017.
Map is not supported in Internet Explorer.