If vs else if vs elsif – What’s the difference?

Words like if and else if can be very tricky and confusing at times. Most people fail to differentiate them and avoid using them. While, in some cases, both can be used interchangeably, it is not always the same. They both are different and are applicable in different contexts.

In fact, if is a more common term in English grammar than else if. Else if is a vocabulary that is mainly used in the JavaScript and not in informal English dialogue. Let us look at these words in detail.

If is a term in English grammar that basically provides a condition. While using if, there should always be a conditional construct. Its main aim is to introduce a conditional clause to the sentence and act as conjunction. The situation or condition introduced may or may not be real.

For example:

  • If it rains again, I am cancelling all the plans for tomorrow.
  • You can visit me or call me up if you are in need of any help.
  • If there is any problem, I will come by at any time.

Else if/elsif, on the other hand, is used strictly in a computer programming language that also introduces conditions. It is rarely seen in informal English writing. In simple words, we can say that Else if /elsif is a common form of conditional statements in computer programming. It tells the computer that if the condition is true, do this. Else, if the condition is false, do another thing.

So, this is the difference between the two. While if and else if look the same, both have distinct functions.

Leave a Comment