Is the ";" (End Of Line) best practice in the Javascript Language?

I know that using the “;” is not required, per say. Is it best practice to add this at the end of lines? I coded JS in the past and have not used this all the time, most of the time, if I use it, it’s out of habit from other languages.

Essentially:
1: let myVariable = 1
1: let myVariable = 1 ;

Any reason to pay attention to “;” ?

Hello @rbtprgmr. This article explains it well. You are essentially correct, though.

2 Likes

I kind of chuckled at this one. I guess it if matters in any instance, I’ll get in habit of ; after all if not most. I just noticed in past projects it works but then again i’m putting returns at end vs beginning etc. Good find on article.

function getCheese() {
    return; 
    { 
       cheeseType: "Gouda"
    } 
  }
2 Likes