InterviewHubPRO
Section Overview
Q178

Question 178 of 521

Part 4: Prototypes, Object Methods & Event Loop (174 - 253)

34%
JavaScript Internals (521 Qs)•Part 4: Prototypes, Object Methods & Event Loop (174 - 253)

What is a conditional operator in javascript

The conditional (ternary) operator is the only JavaScript operator that takes three operands which acts as a shortcut for if statements.

javascript
  var isAuthenticated = false;
  console.log(
    isAuthenticated ? "Hello, welcome" : "Sorry, you are not authenticated"
  ); // Sorry, you are not authenticated