Identity and Equality : String Comparison « Data Type « JavaScript DHTML






Identity and Equality

   
<html>
<head>
<title>Identity and Equality</title>
<script type="text/javascript">

var sValue = "3.0";
var nValue = 3.0;

if (nValue == "3.0") document.write("According to equality, value is 3.0");

if (nValue ==="3.0") document.write("According to identity, value is 3.0");  

if (sValue != 3.0) document.write("According to equality, value is not 3.0");

if (sValue !== 3.0) document.write("According to identity, value is not 3.0");

</script>
</head>
<body>
<p>Some page content</p>
</body>
</html>

   
    
    
  








Related examples in the same category

1.Compare string against integer with a strict test
2.Compare string against integer against simple test
3.If a lower case string is greater than, equal to, or less than the same string in upper case characters.
4.Comparing two strings