Difference between == & === in JavaScript
== Check value only.
=== Check value and its type also.
<!DOCTYPE html>
<html
lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Difference between == &
=== in JavaScript</title>
</head>
<body>
<script type="text/javascript">
var b = true;
if (b == 1)// return true
{
document.writeln("Check value
only");
}
if (b === 1)// return false as variable
"b" is boolean type and "1" is number
{
document.writeln("Check value and its
type also");
}
</script>
</body>
</html>
Comments
Post a Comment