While you can write JS code without semicolons, you'll run into cases where you'll have to replace them with something different that is easily forgotten, like the following bug:
console.log('the next line will produce an error)
(function() { console.log('this is a normal IEFE') })()
each line by itself will work, but together, they will fail, because the IEFE will be interpreted to be an argument to the function output of the first line. To fix that, you'd have to put a ! in front of the IEFE or a semicolon at the end of the first line.
Since it is easier to forget the first than to remember the second - at least if you put a semicolon at the end of each statement, you'll see why this is a best practice.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
While you can write JS code without semicolons, you'll run into cases where you'll have to replace them with something different that is easily forgotten, like the following bug:
each line by itself will work, but together, they will fail, because the IEFE will be interpreted to be an argument to the function output of the first line. To fix that, you'd have to put a
!
in front of the IEFE or a semicolon at the end of the first line.Since it is easier to forget the first than to remember the second - at least if you put a semicolon at the end of each statement, you'll see why this is a best practice.