Files
rust_browser/tests/external/js262/fixtures/ternary-complex.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

12 lines
256 B
JavaScript

// Ternary with various operators and function calls
function double(n) { return n * 2; }
var a = 1 > 0 ? double(5) : double(10);
console.log(a);
var b = 0 || false ? "truthy" : "falsy";
console.log(b);
var c = true && 1 ? "yes" : "no";
console.log(c);