JavaScript is congruent with the equal sign

In JavaScript, == === with other relational operators and values ​​are the same boolean value is true, but the two conditions are not the same, as long as both sides == content, even if the data type is not the same, the return value is true; but both ends === must be strictly congruent, that is, content and data type to be the same, only the value of the expression is true, the following is an example: 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script>
			function test(){
				console.log(5==5);
				console.log(5=='5');
				console.log(5==='5');
			}
		</script>
		<b οnclick="test()">按钮</b>
	</body>
</html>

Published 99 original articles · won praise 93 · views 5231

Guess you like

Origin blog.csdn.net/DangerousMc/article/details/102651967