+ 3
What is the use of ; in JavaScript
Please tell me
5 Réponses
+ 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.
+ 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.
+ 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 ☺
+ 1
I got my answer