JavaScript Strict Mode

The Strict mode is a way of checking error in your code. The strict mode "use strict"; which defines that JavaScript code should be executed in "strict mode". The main purpose of strict mode is to check more deeply JavaScript code, and remove the vulnerability on the code.

Declaring Strict Mode :

The strict mode is declared by adding "use strict"; to the beginning of a script or a function. It is declared at the beginning of a script and it has global scope. Example :
<html>
<head>
  <title>String Operators</title>
</head>
<body>
  <script type="text/javascript">
    "use strict";
    var str = "This is First String. ";
    var x = 200;
    var mystr = str + x;
    document.write(mystr);
    </script>
</body>
</html>
Output :



Next Topic :