I've been looking fot a decent answer for days. Some people just say "map is better when dinamically removing/adding (key, value)" or "you should use map when all keys are the same datatype and all values are all the same datatype". But why???
Asked
Active
Viewed 233 times
1
-
Dynamic keys on objects have problems due to possible shadowing or invoking of `Object.prototype` methods. I think Maps are also more efficient in such situations due to the hidden classes of objects in V8. I have no idea about the second quote in your question, never heard that before, it looks suspect to me – CertainPerformance Aug 05 '21 at 02:28
-
But considering let a = Object.create(null); there's NO prototype, but map still much faster.. (I have a script whereas i'm testing which is faster). And what you do mean by "hidden classes of objects", how could this increase performance? – jones_root Aug 05 '21 at 02:39
-
https://stackoverflow.com/questions/40323217/how-are-hidden-classes-in-the-v8-engine-implemented https://engineering.linecorp.com/en/blog/v8-hidden-class/ etc - google shows a lot of links – CertainPerformance Aug 05 '21 at 02:40
-
I didn't know about the term, thanks. But hidden classes are implemented for both Map and Object right? then it still not making sense to me – jones_root Aug 05 '21 at 04:19