Y
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
temporarysdwvit
2171 days ago
Oh you can, just implement toString and js will use it for hashing
link
IshKebab
2170 days ago
No it won't.
link
yqot
2170 days ago
Map, no. Plain object, yes.
link
IshKebab
2166 days ago
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).
link