SoFunction
Updated on 2025-03-06

A brief discussion on the automatic conversion and statements of JavaScript variables

JS automatic type conversion

var a = 1;
var b = true;

"==" means that it can be converted automatically, and the comparison is a numerical value.
"===" means that you can convert the type automatically, first compare the values, then compare the types

if (a == b) {
alert("equal"); //Print
}else{
alert("unequal");
}

Three-mean operation

var c = 10/2 > 4 ? 5 : 3 ;
alert(c);

About the for loop

for ( var i = 0; i < 5; i++) {
alert(i);
}

A dead cycle

for(;;){
alert("executive body");
}

The above brief discussion on the automatic conversion and sentences of JavaScript variables is all the content I have shared with you. I hope you can give you a reference and I hope you can support me more.