mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 16:59:43 +01:00
In a realm with `Options::es2015`, `Date.prototype[Symbol.toPrimitive]` converts with `toString` first for the hints "string" and "default" and with `valueOf` first for "number" (ECMA-262 11th edition, section 20.4.4.45). An object without an `@@toPrimitive` method, a Date whose own method is `null` or `undefined` included, converts without a hint with `valueOf` first (section 7.1.1.1), so `d + 1` gives 8 when `valueOf` returns 7. A realm without the option keeps the ES5 order for a Date. `JSON.stringify` converts a Number or String object with ToPrimitive. A `valueOf` or `toString` deleted from the object's own prototype is now looked up further along the chain, so `Object.prototype.toString` is called instead of the stored primitive value being returned. A Symbol that an object's `@@toPrimitive` method gives as a property key is rooted while the property is read or incremented, so it and its description still count against the heap when a getter starts a collection.