0
Is it necessary to end a code with ; in javascript
Pls tell where to use it in variable , constants and where else
2 Answers
+ 2
No we don't have to, except in for loop
for(let i = 0; i <= 10; i++) {
}
Here we chain statements and we need to use it
But in other cases code will mostly work without it
Browsers understand end of line as ";"
So if you don't have anything after statement, ";" is not needed
Make sure you stick to same style when coding, if you used already ";" in your code, then use it thought full code.
Maybe some tools to minify code(or similar) will break if ";" is not used, so if you use this tools, read documentation and make sure it won't make problems, before you start to type your code.