Is it necessary to end a code with ; in javascript | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Is it necessary to end a code with ; in javascript

Pls tell where to use it in variable , constants and where else

25th Dec 2022, 11:29 AM
Harsh Rana
Harsh Rana - avatar
1 Respuesta
+ 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.
25th Dec 2022, 1:07 PM
PanicS
PanicS - avatar