Skip to content

Instantly share code, notes, and snippets.

@arnorhs
Created May 3, 2020 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnorhs/2751890da9969f22dfc1035a6542c7a2 to your computer and use it in GitHub Desktop.
Save arnorhs/2751890da9969f22dfc1035a6542c7a2 to your computer and use it in GitHub Desktop.
string hash code
const strHash = str => {
let hash = 0
for (let i = 0; i < str.length; i++) {
let charCode = str.charCodeAt(i)
hash = (hash << 5) - hash + charCode
hash = hash & hash
}
return hash
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment