Files
rust_browser/tests/external/js262/fixtures/delete-operator.js
Zachary D. Rowitsch 13b610be03
All checks were successful
ci / fast (linux) (push) Successful in 6m27s
Add JavaScript delete, void, and in operators
Implement three missing JS operators that together unblock 57 Test262
full-suite tests (pass rate 42% → 44%):

- delete: reference-aware unary operator that removes object properties,
  with special handling for member/computed/identifier expressions
- void: unary operator that evaluates operand and returns undefined
- in: binary operator that checks property existence via prototype chain,
  gated by allow_in flag to disambiguate from for-in loops

The allow_in mechanism (with_no_in helper) prevents the parser from
consuming `in` as a binary operator inside for-loop initializers, which
would break for-in/for-of parsing.

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

27 lines
625 B
JavaScript

// delete on object member property
var o = {x: 1, y: 2};
var r1 = delete o.x;
console.log(r1); // true
console.log(o.x); // undefined
console.log(o.y); // 2
// delete on computed member
var o2 = {a: 10};
var r2 = delete o2["a"];
console.log(r2); // true
console.log(o2.a); // undefined
// delete on declared variable returns false
var v = 42;
console.log(delete v); // false
// delete on non-reference returns true
console.log(delete 42); // true
// delete on function property
function f() {}
f.custom = 99;
console.log(f.custom); // 99
delete f.custom;
console.log(f.custom); // undefined