CodesJava

Easy learning with example program codes

typescript conditional operator tutorial


Typescript Conditional Operator:

Typescript conditional operator is used as a shortcut for the if statement. It takes three operands. If condition is true, the operator returns the value of expr1 otherwise it returns the value of expr2.

Typescript Conditional Operator Syntax:

condition ? expr1 : expr2

TypeScript Conditional Operator Example:

var num:number = 10; 
var result = num > 0 ?"positive":"negative" ;
console.log(result);

Try it:

JS Bin on jsbin.com
 

Please follow and like us:


Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki