How to calculate hash code for N hash codes? To calculate hash code for the collection like Array?
Number.prototype.hashCode = function() { return this }
String.prototype.hashCode = function() { return cyrb53(this) }
Array.prototype.hashCode = function() { ??? }
It’s not for security, for hashing etc. so something similar to Java hashCode would be ok.
P.S.
If that matters, for Number hash code is same as the number itself, for String cyrb53
from Generate a Hash from string in Javascript
2
Answers
I convert Nim
!&
Hash operator to JSOriginal Nim code
You’re gonna have to hash the contents of the array anyway, so you might as well stringify the whole thing: