function stringHash(string) {
    var hash = 0;
    var length = string.length;

    for (var i = 0; i < length; i++) {
        hash = ((hash * 31) + string.charCodeAt(i)) & 0x7fffffff;
    }

    return (hash === 0) ? 1 : hash;
}
/**
 * String hash, similar to Java's definition.
 */
String hash, similar to Java's definition.
String hash similar to Java ' s definition .
function stringHash(string) {
    var hash = 0;
    var length = string.length;
    for (var i = 0; i < length; i++) {
        hash = ((hash * 31) + string.charCodeAt(i)) & 0x7fffffff;
    }
    return (hash === 0) ? 1 : hash;
}
function stringHash ( string ) { var hash = 0 ; var length = string . length ; for ( var i = 0 ; i < length ; i ++ ) { hash = ( ( hash * 31 ) + string . charCodeAt ( i ) ) & 0x7fffffff ; } return ( hash === 0 ) ? 1 : hash ; }
String hash, similar to Java's definition.
String hash similar to Java ' s definition .