Hacker News new | ask | show | jobs
by gilnaa 2171 days ago
I was quite surprised to read that you can't set a custom hasher in C++/Rust, and I even went and made sure that it's possible.

But then I re-read your comment and realized you've meant that you can't do this in JS.

1 comments

Oh you can, just implement toString and js will use it for hashing
No it won't.
Map, no. Plain object, yes.
It doesn't "use `toString` for hashing", it just converts the key to a string. That is not the same (e.g. you can't recover the original key).