• flickr
  • linkedin
  • twitter
  • rss
if else questionmark operators

if else questionmark operators

A neat wee time saving way to write an if () {} else {} statement in flash or javascript:

var a = true;
var b = false;
var c;
if(a==b?c = true: c = false);

The statements between the ? and the : are if the if evaluated to true, and after the : is for false. Ie. it is this:

if(a == b) {
  c = true;
} else {
  c = false;

and if you’re just going for an if, no else, just throw a null in the 2nd assignment

Tech Reference: ,

Larry's a 30-something chap interested in travel, being a dork and changing the world via less boring training.

Leave a reply