What does “use strict” do in JavaScript, and what is the reasoning behind it?

Table of Contents

The directive “use strict” refers to a literal expression. JavaScript 1.8.5 introduced it. It is named “use strict” because it indicates that the code was executed in strict mode.

Let us declare strict mode. Add the keyword “use strict”, at the beginning, to declare strict mode. Declare it at the start of the script for global scope.

Example

<!DOCTYPE html>
<html>
   <body>
      <p>An error would come, since you have used a variable, but forgot to declare it</p>
      <p>Press F8 to see the error.</p>
      <script>
          "use strict";
          a = 1;
       </script>
    </body>
</html>

 

 

 

How Lack of Rest Can Impact Your Finances Small Businesses Can Enhance File Management Following these Tips How Much Do Real Estate Agents Spend on Marketing? How to Engage Your Online Audience for Long-Lasting Success Why is Plagiarism Such a Big Deal? Resume Service Review: Why Everyone Should Use It
adbanner