Ternary Operator
JS · Control Flowsyntax
condition ? valueIfTrue : valueIfFalseexample
const age = 20;
const category = age >= 18 ? "adult" : "minor";
console.log(category); // "adult"
// Nested (use sparingly)
const tier = age >= 65 ? "senior" : age >= 18 ? "adult" : "minor";Note Great for simple inline conditions. Avoid deeply nested ternaries -- they quickly become unreadable. Use if/else for complex logic.