Returns a hash of value that agrees with equals: equal values have equal hashes.
An object implementing both [equalsSymbol] and [hashCodeSymbol] is hashed by
value[hashCodeSymbol](hashCode), reduced to a 32-bit integer. Primitives are hashed by value
(with NaN alike and -0 as 0) without calling any user code; other objects, functions and
classes by identity (for an object, only its two protocol keys are read, which can run a getter
or a Proxy trap). Hash values are seeded: they differ between runs and between
loaded copies of the library, so never store or send them.
Time: O(1) for numbers, booleans, null and undefined; O(1) amortised for objects; O(length)
for strings and symbol descriptions; O(digits) for bigints; plus the [hashCodeSymbol] method
when one is called.
Parameters
value: unknown
Any value.
Returns number
A 32-bit integer.
Throws
TypeError when [hashCodeSymbol] returns a value that is not a finite number, or the
object implements only one of [equalsSymbol] and [hashCodeSymbol].
Returns a hash of
valuethat agrees with equals: equal values have equal hashes.An object implementing both
[equalsSymbol]and[hashCodeSymbol]is hashed byvalue[hashCodeSymbol](hashCode), reduced to a 32-bit integer. Primitives are hashed by value (withNaNalike and-0as0) without calling any user code; other objects, functions and classes by identity (for an object, only its two protocol keys are read, which can run a getter or aProxytrap). Hash values are seeded: they differ between runs and between loaded copies of the library, so never store or send them.Time: O(1) for numbers, booleans,
nullandundefined; O(1) amortised for objects; O(length) for strings and symbol descriptions; O(digits) for bigints; plus the[hashCodeSymbol]method when one is called.