1

Now that JavaScript has Maps that can actually use primitives or objects as keys, are there still good reasons to roll out your own implementation of a hash map(table) using a hash function and dealing with collisions and all that jazz? If so, what are they?

snowfrogdev
  • 3,631
  • 2
  • 22
  • 40
  • 1
    One reason could be to support older browsers?! – Teemoh Apr 14 '18 at 17:20
  • @Teemoh Good point. I've been using TypeScript to write in ESNext for so long now and letting it worry about transpiling down to prehistoric JS that it never really occurred to me. ;-) – snowfrogdev Apr 14 '18 at 17:34

1 Answers1

2

Rolling your own Map implementation does allow you to control its internals. This does allow you to use a custom equality comparison between keys, and use a hash function that is optimised for the keys in your application.

Bergi
  • 513,640
  • 108
  • 821
  • 1,164