Files
rust_browser/tests/external/js262/fixtures/to-primitive-valueOf.js
Zachary D. Rowitsch b5416b31d7
All checks were successful
ci / fast (linux) (push) Successful in 6m23s
Add ToPrimitive coercion and primitive wrapper objects (Number/String/Boolean)
Implement ECMA-262 §7.1.1 ToPrimitive/OrdinaryToPrimitive algorithm with
valueOf/toString method dispatch, wrapper objects via new Number/String/Boolean,
bare-call semantics (Number(42) → primitive), and primitive auto-boxing for
method calls like (42).toString(). Updates all operator coercion points
(arithmetic, comparison, equality, bitwise, unary, update, compound assignment,
template literals) to use ToPrimitive. Promotes 440+ Test262 tests to pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 21:18:08 -05:00

7 lines
155 B
JavaScript

// ToPrimitive via valueOf
var o = {valueOf: function() { return 42; }};
console.log(o + 1);
console.log(o - 1);
console.log(o * 2);
console.log(o == 42);