0
In JavaScript if semicolon not present does the code get affected by without semicolon? What's the difference?
I tried but I didn't get error without semicolon.
2 Answers
+ 2
With semicolon you can write more than 1 expression in single line
c=b;b=a;a=c;
Without semicolon you need to seperate each expression by line
c=b
b=a
a=c
+ 2
But it is overally better to write them even when using linebreaks just to be sure. It could work without but when you do bigger projects it is frustrating when you have to put all missing semicolons in place becase it is not working.