Než gizdiť proto, radšej by som z toho urobil obyčajnú funkciu:
function hashCode(text) {
    var hash = 0;
    if (text.length == 0) {
        return hash;
    }
    for (var i = 0; i < text.length; i++) {
        var char = text.charCodeAt(i);
        hash = ((hash<<5)-hash)+char;
        hash = hash & hash; // Convert to 32bit integer
    }
    return hash;
}
používať proto má zmysel u vlastných typov či tried.
 
 
