I'm a beginner and learning data structures and algorithms.
I came to know a new data structure called Map.
I am confused why Map is created like this:
const countMap = new Map()
This is unlike other data structures like array where we simply write let array = [];
I searched about this Map syntax and found about constructors and instances etc
If I am correct then I heard about them in OOP. Now should I first learn OOP then continue DSA or what do you suggest?
Rory McCrossan
338k41 gold badges322 silver badges353 bronze badges
Explore related questions
See similar questions with these tags.
lang-js
Map()and edit the question to give specific details of where you need assistance.let array = [];is just syntactic sugar. It's still calling the Array constructor under the hood, eg:let array = new Array();new Object()andnew Array()to create empty object and array as well.{}and[]are literal syntaxes for those. There is no literal to create an empty Map.