Comparing two strings : String Comparison « Data Type « JavaScript DHTML






Comparing two strings

   


<html>
  <head>
    <title>Comparing two strings</title>
    <script type="text/javascript">
        var a = "C";
        var b = "J";
        
        if (a == b)
        {
            var identity = "same";
        }
        else
        {
            var identity = "different";
        }
        
        document.write(a + " and " + b + ": " + identity);    
    </script>
  </head>
  <body>
  </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.Identity and Equality