Files
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

26 lines
665 B
JavaScript

// own property
console.log("x" in {x: 1}); // true
console.log("y" in {x: 1}); // false
// prototype property
function Animal() {}
Animal.prototype.legs = 4;
var a = new Animal();
console.log("legs" in a); // true
console.log("wings" in a); // false
// property with undefined value still counts
var o = {z: undefined};
console.log("z" in o); // true
// function properties
function f() {}
f.custom = 1;
console.log("custom" in f); // true
console.log("missing" in f); // false
// numeric key coercion
var arr = [10, 20, 30];
console.log(0 in arr); // true
console.log(5 in arr); // false