A Shorter IF Statement

While a conventional if statement is relatively easy to read, it can be a bit long-winded in what you need to type in order to make decisions. Where the decision that is to be made is which of two or more possible values is to be assigned to a specific field, JavaScript provides an alternative notation that can be used to combine the decision making process into the assignment statement itself. This shorter way of defining an if else condition can’t be used just anywhere and it is not as easy to read as a normal if statement but it is much shorter to write and should lead to more efficient processing in those situations where it can be used.

A Shorter IF Statement

Share and Enjoy:
  • Digg
  • del.icio.us
  • Furl
  • description
  • StumbleUpon

Tags: , , ,

Leave a Reply