Home > Article > Web Front-end > Detailed explanation of JavaScript string judgment method
The main judgment symbols in
Javascript are: ==,! =、===、! ==
==、! =These two symbols will first convert the variabletype before judging. If the types are the same, the values will be compared;
===,! == This is to directly judge the types of two variables. If the types are inconsistent, the judgment will be made directly without comparing the values.
demo:
function bijiao(){
var str="123";
var num=123;
var char='123';
alert(srt==num);//true
alert(str==char);//true
alert(str= ==num);//false
alert(str!==num);//true
}
The above is the detailed content of Detailed explanation of JavaScript string judgment method. For more information, please follow other related articles on the PHP Chinese website!