Node.js examples for String:String Value
Add hash code method to String
String.prototype.hashCode = function() { var hash = 0, i, chr, len;//from w ww .ja v a2 s . c o m if (this.length == 0) return hash; for (i = 0, len = this.length; i < len; i++) { chr = this.charCodeAt(i); hash = ((hash << 5) - hash) + chr; hash |= 0; // Convert to 32bit integer } return hash; };