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" ;

Try it:

JS Bin on

Please follow and like us:

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki