How to do case-sensitive string comparison in JavaScript?

JavascriptWeb DevelopmentFront End Technology

As JavaScript is case sensitive, so case-sensitive comparison are simple string comparisons. This can be done without using any JavaScript method:

<!DOCTYPE html>
<html>
   <body>
      <h3>JavaScript Strings</h3>
      <p id="test"></p>
      <script>
         var str1 = "amit";
         if (str1 === "amit") {
            document.getElementById("test").innerHTML = "correct"
         }
      </script>
   </body>
</html>
raja
Published on 22-Jan-2018 14:09:30
Advertisements