Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript ternary operator

// condition ? expr1 : expr2

// example:

let bar = 2
let foo = 0
let result;

result = bar > foo ? 1 : -1; // result = 2 > 0 ? 1 (true) : -1 (false);

// output: result = 1 
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #javascript #ternary #operator
ADD COMMENT
Topic
Name
7+2 =