Skip to content

Instantly share code, notes, and snippets.

@117
Created November 19, 2020 07:11
Show Gist options
  • Save 117/8eb7153ce93497ca21fbb0a07a04c50c to your computer and use it in GitHub Desktop.
Save 117/8eb7153ce93497ca21fbb0a07a04c50c to your computer and use it in GitHub Desktop.
hashcode function for any javascript object
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