Created
November 19, 2020 07:11
-
-
Save 117/8eb7153ce93497ca21fbb0a07a04c50c to your computer and use it in GitHub Desktop.
hashcode function for any javascript object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hashcode(object) { | |
let json = JSON.stringify(object) | |
for (var i = 0, h = 0; i < json.length; i++) | |
h = (Math.imul(31, h) + json.charCodeAt(i)) | 0 | |
return h | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment