Why are multiple semicolons allowed on one line in Javascript? What is really happening here?
var x = 5;;;;;;;;;;
console.log(x);;;;;
Why are multiple semicolons allowed on one line in Javascript? What is really happening here?
var x = 5;;;;;;;;;;
console.log(x);;;;;
A semi colon is a statement separator. By itself it creates an empty statement which, if you can say it is "executed" has no effect.
Multiple semicolons in a row simply create multiple consecutive empty statements and serve no practical purpose in code terms.
Deliberate use of empty statements may cause confusion and usually have alternatives. For example:
if( condition)
;
else {
// do something
}
is more clearly coded as
if( !condition) {
// do something
}