Here's a shot at what you're seeing. It sounds like you're a C++ guy who's new to JS, so I'm going to walk you through some of the basics and we'll wrap up with a nice demo.
1) Map is not the term for what you're doing.
Using the word map is confusing some people here because in JS, map is actually a function on an array that you can use to change the shape of it's data. What you're doing instead is creating an Object. Javascript objects are dynamic, and so adding properties on the fly is completely reasonable, and that's the premise of your situation. You want to add lots of properties to a dynamic object.
2) Without an example, your question is vague
It's hard to decipher what is taking "a long time" to run on your machine. Is this server-side JS or client-side? Have you used the cool new multi-core stuff? Are you creating 100,000 objects or simply adding 100,000 properties to a single object? As a C++ guy, you should know better than to be so vague. Creating an object allocates memory, and everyone in C++ knows that memory allocation is heavy. So that one bit of information can make a huge difference.
3) The speed of JS is slower than C++
Period. C++ is a lower level language. In order to do things automatically for you (like allocating memory) higher level languages are inherently slower. This is not to mention the overhead imposed by your browser.
4) Most optimizations are out of your hands
Unless you're working in binary (note: not assembly, binary) the commands you're working with are interpreted by software. That interpreter's speed is not something you can make a huge impact on. As a lightweight example, client-side JS is affected by the speed of the browser, the speed of the user's processor, the speed of the user AND server's networks in unison, the number of requests, lag time for AJAX calls, and even the number of other things the user is doing on their computer at a given time.
5) It's not that slow. Let's look at some real data points.
Below you'll see that it's less that 1/10th of a second (on my machine atm) to add 100,000 properties to one object, and only slightly slower (still less than 1/10 of a second) to create 100,000 objects and add 1 property to each.
We up the time (almost 2/10 of a second) a lot by logging it to the console, but even that isn't our fault, or something you should be encountering in optimized code.
WARNING, RUNNING THIS CODE SNIPPET WILL HANG YOUR BROWSER FOR A FEW SECONDS
var start = new Date().getTime();
var obj1 = {};
for (var i = 0; i < 100000; ++i) {
obj1[i.toString()] = 'test';
}
var end = new Date().getTime();
var time1 = end - start;
console.log(obj1);
end = new Date().getTime();
var time2 = end - start;
start = new Date().getTime();
for (var i = 0; i < 100000; ++i) {
var obj2 = {};
obj2[i.toString()] = 'test';
}
end = new Date().getTime();
var time3 = end - start
console.log(time1);
console.log(time2);
console.log(time3);