Skip to main content
InterviewHubPRO
Section Overview
Q178

Question 178 of 536

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

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

What is a conditional operator in javascript

junior LevelMost AskedCode ExampleEvent LoopPrototypes

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