Shortcut for if-else in JavaScript

JavaScript has C-like syntax. Therefore, it is possible to use the ?: conditional operator, which is a shortcut for the if-else block:

 Expression?true part:false part

Try this example:

 
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: