Created
August 25, 2014 19:14
-
-
Save neocris/2683359536d96c89264c to your computer and use it in GitHub Desktop.
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
String.prototype.hashCode = function(){ | |
var hash = 0; | |
if (this.length == 0) return hash; | |
for (i = 0; i < this.length; i++) { | |
char = this.charCodeAt(i); | |
hash = ((hash<<5)-hash)+char; | |
hash = hash & hash; // Convert to 32bit integer | |
} | |
return hash; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment