@@ -131,7 +131,7 @@ ultimate source of truth. Upstream test262 files run verbatim from `test/test262
131131- [x] Built-in method references as callbacks, such as ` values.map(Math.abs) ` , ` records.map(JSON.stringify) ` ,
132132 ` items.forEach(console.log) ` , and ` Promise.resolve(-1).then(Math.abs) ` . Extra callback arguments a built-in
133133 does not consume are ignored, like JS, and consumed arguments coerce, like JS (`"3.7".replace(/\d\. \d/,
134- Math.floor)` is ` "3"` ). A detached method loses its receiver, as in JS: ` values.filter("abc".includes)` is a ` TypeError`
134+ Math.floor)` is ` "3"` ). A detached method loses its receiver, as in JS: ` values.filter("abc".includes)` is a ` TypeError`
135135 because ` includes ` is called without a string ` this ` .
136136- [x] Constructors work as callbacks with JS call semantics: ` Error ` types construct (` messages.map(Error) ` ),
137137 and new-requiring constructors (` Map ` , ` Set ` , ` URL ` , ` URLSearchParams ` , ` Headers ` , ` Promise ` ) throw a ` TypeError ` ,
@@ -155,8 +155,9 @@ ultimate source of truth. Upstream test262 files run verbatim from `test/test262
155155 array, an array-like object (its ` length ` clamped and capped like ` Array.from ` ), or ` null ` /` undefined ` . A
156156 bound function is named ` bound f ` , has its remaining ` length ` , and is not constructible.
157157- [x] ` JSON.parse ` revivers and ` JSON.stringify ` function replacers see the holder object as ` this ` .
158- - [ ] The optional ` thisArg ` of iteration methods (` map ` , ` forEach ` , ` Map.prototype.forEach ` , ` Array.from ` , …) is
159- accepted but not yet passed as ` this ` ; callbacks run with ` this ` undefined.
158+ - [x] The optional ` thisArg ` of the Array, Uint8Array, and ` Array.from ` callback methods and of Map, Set,
159+ URLSearchParams, and Headers ` forEach ` is the callback's ` this ` : ` [1, 2].forEach(function () { this.n++ }, c) `
160+ increments ` c.n ` twice. Arrows ignore it, as in JS; ` reduce ` /` reduceRight ` take an initial value instead.
160161- [ ] User-defined constructor calls.
161162- [ ] Classes and private fields.
162163- [x] Functions are objects: they hold own properties (` fn.count = 1 ` ), enumerate them, and expose read-only ` name `
@@ -241,11 +242,19 @@ ultimate source of truth. Upstream test262 files run verbatim from `test/test262
241242 throws: ` { valueOf() { return 7 } } * 2 ` is ` 14 ` , `` `${{ toString() { return "x" } }}` `` is ` "x" ` , and
242243 ` [1, 2] ` with ` arr.toString = () => "x" ` makes ` arr + "" ` ` "x" ` . Dates keep their ` Symbol.toPrimitive `
243244 behavior (` date + 1 ` concatenates, ` date - date ` subtracts).
244- - [ ] ToPrimitive elsewhere: ` Error.prototype.toString ` on an object ` message ` and numeric built-in arguments outside
245- ` Math ` and ` Date ` (` at ` , ` indexOf ` start, ` toFixed ` digits) still use the built-in form (` NaN ` ,
246- ` "[object Object]" ` ) and ignore own methods.
247- - [x] Property keys follow ToPropertyKey: ` x[null] ` , ` x[true] ` , and objects (via their built-in string form) become
248- string keys.
245+ - [x] String and Number method arguments convert through ToPrimitive in spec order, receiver first: search strings,
246+ separators, fills, and replacements with the string hint, indexes, counts, digits, and radixes with the number
247+ hint (` "abc".indexOf({ toString() { return "b" } }) ` is ` 1 ` , ` (255).toString({ valueOf() { return 16 } }) ` is
248+ ` "ff" ` , ` String.prototype.trim.call({ toString() { return " a " } }) ` is ` "a" ` ). Only consumed positions
249+ convert; a RegExp pattern is used as is, and ` includes ` /` startsWith ` /` endsWith ` reject one before converting.
250+ - [ ] ToPrimitive elsewhere: ` Error.prototype.toString ` on an object ` message ` and numeric arguments of the Array and
251+ Uint8Array methods (` at ` , ` indexOf ` start, ` slice ` ) still use the built-in form (` NaN ` , ` "[object Object]" ` ) and
252+ ignore own methods.
253+ - [x] Property keys follow ToPropertyKey: ` x[null] ` and ` x[true] ` become string keys, and a data object key
254+ converts through its own ` toString ` /` valueOf ` (string hint) exactly once per access, in reads, writes,
255+ compound assignment, ` ++ ` , ` delete ` , ` in ` , object literals, and destructuring:
256+ ` o[{ toString() { return "id" } }] += 1 ` updates ` o.id ` . A nullish base throws before the key converts, as
257+ in JS. Opaque values (functions, promises, tool references) keep their built-in string form.
249258
250259## Promises and tools
251260
@@ -306,8 +315,9 @@ reject }` object.
306315- [x] ` Object() ` and ` new Object() ` return ` {} ` for nullish arguments and pass objects through unchanged;
307316 primitive wrapper objects (` Object(1) ` ) are rejected explicitly.
308317- [x] Computed property names and object spread. Any value works as a key (ToPropertyKey): strings, numbers, and the
309- two confined symbols as themselves, everything else as its string form (` o[null] ` is ` o["null"] ` , ` o[{}] ` is
310- ` o["[object Object]"] ` ), in reads, writes, literals, ` in ` , and destructuring.
318+ two confined symbols as themselves, data objects through their own ` toString ` (` o[[1, 2]] ` is ` o["1,2"] ` ), and
319+ everything else as its string form (` o[null] ` is ` o["null"] ` ), in reads, writes, literals, ` in ` , and
320+ destructuring.
311321- [x] ` Object.keys ` , ` Object.values ` , ` Object.entries ` , ` Object.hasOwn ` , ` Object.assign ` , and ` Object.fromEntries ` , with
312322 synchronous iterator support for ` fromEntries ` . Sources follow ToObject: strings enumerate by index, other
313323 primitives and wrappers contribute nothing, and ` null ` /` undefined ` throw. ` Object.assign ` accepts array
@@ -368,7 +378,6 @@ reject }` object.
368378 shares one prototype, where JavaScript gives each collection its own; ` Object.getPrototypeOf ` shows the
369379 difference.
370380- [x] ` length ` , numeric indexing, index assignment, spread, and ` for...of ` .
371- - [x] The ` thisArg ` argument of ` Array.from ` is accepted and ignored, like JS arrows.
372381- [x] ` Array.prototype.toSpliced ` .
373382- [x] Canonical array/string index parsing: keys such as ` "01" ` are ordinary properties rather than aliases of index
374383 ` 1 ` .
@@ -381,9 +390,9 @@ reject }` object.
381390 ` flat(1.9) ` , ` with(1.5, v) ` , ` Math.max("3", "2") ` , ` parseInt("11", "2") ` , ` (1.5).toFixed("2") ` ,
382391 ` String.fromCharCode("65") ` , and the Uint8Array equivalents. ` join(sep) ` and ` JSON.parse(text) ` apply ToString
383392 (` join(null) ` is ` "1null2" ` , ` JSON.parse(123) ` is ` 123 ` ). ` Array.from({ length: "2" }) ` applies ToLength; a
384- promise source still throws with an ` await ` hint rather than JS's silent ` [] ` . ` join ` , ` Math.* ` , and
385- ` parseInt ` consult a program object's own ` valueOf ` /` toString ` ; the array and number methods do not yet (see
386- ToPrimitive above).
393+ promise source still throws with an ` await ` hint rather than JS's silent ` [] ` . ` join ` , ` Math.* ` , ` parseInt ` ,
394+ and the String and Number methods consult a program object's own ` valueOf ` /` toString ` ; the array methods do not
395+ yet (see ToPrimitive above).
387396
388397## Strings
389398
@@ -400,14 +409,15 @@ reject }` object.
400409- [x] Static ` String.fromCharCode ` and ` String.fromCodePoint ` .
401410- [x] Native argument coercion for supported String methods; for example, ` includes(1) ` and ` slice("1") ` coerce like
402411 native JS, ` split(undefined) ` returns the whole string, and ` includes ` /` startsWith ` /` endsWith ` reject regular
403- expressions with a native-style ` TypeError ` . Opaque runtime references still reject as data errors, and
404- ` repeat ` still requires a finite non-negative count.
412+ expressions with a native-style ` TypeError ` . Data objects convert through their own ` toString ` /` valueOf ` (see
413+ ToPrimitive above). Opaque runtime references still reject as data errors, and ` repeat ` still requires a finite
414+ non-negative count.
405415- [x] Native no-argument parity for ` match() ` , ` matchAll() ` , and ` search() ` ; all behave as an empty pattern.
406416- [x] ` String.raw ` , on a template object or any ` { raw } ` object; raw strings and substitutions coerce through their own
407417 ` toString ` .
408418- [x] ` match ` , ` matchAll ` , ` search ` , and ` split ` read any non-RegExp argument as a pattern string, as ` new RegExp(arg) `
409- would: ` "a1b".match(1) ` matches ` /1/ ` , ` search(null) ` looks for ` "null" ` , and ` undefined ` is the empty pattern.
410- Objects use their built-in string form until ToPrimitive lands .
419+ would: ` "a1b".match(1) ` matches ` /1/ ` , ` search(null) ` looks for ` "null" ` , ` undefined ` is the empty pattern, and
420+ an object supplies its own ` toString ` .
411421
412422## Numbers and Math
413423
0 commit comments