What is the use of ; in JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the use of ; in JavaScript

Please tell me

29th Apr 2019, 5:29 AM
Kaustuv Anand
Kaustuv Anand - avatar
4 Answers
+ 4
It ends a statement not just in JS but also in C/C++, C#, Java etc. A bit like a period (full stop) in Natural languages.
29th Apr 2019, 6:45 AM
Sonic
Sonic - avatar
+ 2
consider it like this - in HTML we use end tag </> to close most of the tags, in CSS we use ; after writing a property, and in JavaScript we use ; too. so here you are telling to your browser that the particular statement has been end in the ; symbol. after this it will start a new statement. using ; is recommended after writing a statement in JavaScript, However if you not use ; symbol it will work fine, but maybe ..... maybe your code editor will warn you to use the ; in the end of the statement.
29th Apr 2019, 6:04 AM
Bug Slayer
+ 1
We use in loops for count something like chapters ,Array,and obj..... Ex: var x='MBH'; //x.length = 3 alert(1 in x) //true /* *In loop */ for(let i in x) console.log(i) //0 1 2 ,,0 for M ,1 for B... //and of for( let i of x ) document.writeln(x) // MBH, length and write the content in x // try it by yourself ☺
29th Apr 2019, 5:45 AM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 1
I got my answer
30th Apr 2019, 9:25 AM
Kaustuv Anand
Kaustuv Anand - avatar