Good Hash Function for Strings

Usually hashes wouldn’t do sums, otherwise stop and pots will have the same hash. and you wouldn’t limit it to the first n characters because otherwise house and houses would have the same hash. Generally hashs take values and multiply it by a prime number (makes it more likely to generate unique hashes) So you … Read more

How to do associative array/hashing in JavaScript

Use JavaScript objects as associative arrays. Associative Array: In simple words associative arrays use Strings instead of Integer numbers as index. Create an object with var dictionary = {}; JavaScript allows you to add properties to objects by using the following syntax: Object.yourProperty = value; An alternate syntax for the same is: Object[“yourProperty”] = value; … Read more