Home  >  Article  >  Web Front-end  >  Detailed explanation of JavaScript string judgment method

Detailed explanation of JavaScript string judgment method

高洛峰
高洛峰Original
2017-03-12 13:05:261211browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn