Ternary vs Logical OR

Edit on GitHub

ternary vs logical or

Setup

let x = "definedVar";

Tests

  • Ternary

    let z = x ? x : "undefinedVar";
  • Logical OR

    let z = x || "undefinedVar";