JS hashCode function implementation