Files
rust_browser/tests/external/js262/fixtures/ternary-nested.js
Zachary D. Rowitsch 963ac860d2
Some checks failed
ci / fast (linux) (push) Failing after 12m31s
Add JavaScript ternary operator (? :) support
Implements the conditional/ternary operator across tokenizer, parser, and
VM with correct precedence (between assignment and logical-or),
right-associativity, short-circuit evaluation, and nesting depth guard.
Promotes js262-ternary-operator to pass and adds 3 new conformance tests.

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

8 lines
291 B
JavaScript

// Nested ternary — right-associative: a ? b : c ? d : e → a ? b : (c ? d : e)
var a = true ? "first" : false ? "second" : "third";
console.log(a);
var b = false ? "first" : true ? "second" : "third";
console.log(b);
var c = false ? "first" : false ? "second" : "third";
console.log(c);