hashing in javascript

JavaScript
// Convert to 32bit integer 
function stringToHash(string) { 
                  
	var hash = 0; 
                  
    if (string.length == 0) return hash; 
                  
    for (i = 0; i < string.length; i++) { 
        char = string.charCodeAt(i); 
        hash = ((hash << 5) - hash) + char; 
        hash = hash & hash; 
     } 
                  
     return hash; 
}
Source

Also in JavaScript: