Compare string against integer against simple test : String Comparison « Data Type « JavaScript DHTML






Compare string against integer against simple test

  

<html>
<head>
    <title>Equality</title>
    <script type = "text/javascript">
    var x = 2;
    var y = "2";
    if (x == y) {
        document.write("x is equal to y with a simple test.");
    } else {
        document.write("x is not equal to y");
    }
    </script>
</head>
</html>

   
    
  








Related examples in the same category

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