hashString()function
hashString(str: string): number
| Param | Type | |
|---|---|---|
str | string | The string to hash. required |
| Return | |
|---|---|
number | A non-negative number derived from the string's characters. |
Hash a string into an idempotent number.
- Sums the char codes of every character, so the same string always produces the same number.
- Not cryptographically secure — intended for cheap, stable bucketing.
Examples
hashString("abc") // 294