I've even seen implementations that compare objects using
JSON.stringify
.
I would expect a memoizer and most hash code/table implementations to treat { foo: "bar", baz: "quux" }
and { baz: "quux", foo: "bar" }
as equivalent, but many implementations use JSON.stringify
, which doesn't guarantee this:
$ node
> JSON.stringify({ foo: "bar", baz: "quux" })
'{"foo":"bar","baz":"quux"}'
> JSON.stringify({ baz: "quux", foo: "bar" })
'{"baz":"quux","foo":"bar"}'