From 02c55e6497cacff854758e688a43a435c5129a3c Mon Sep 17 00:00:00 2001 From: cksharma2468 Date: Thu, 13 Jul 2023 19:01:33 +0530 Subject: [PATCH 1/2] strict-mode added --- README.md | 50 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f1159781..006542e8 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,18 @@ ## Table of Contents 1. [Introduction](#introduction) -2. [Variables](#variables) -3. [Functions](#functions) -4. [Objects and Data Structures](#objects-and-data-structures) -5. [Classes](#classes) -6. [SOLID](#solid) -7. [Testing](#testing) -8. [Concurrency](#concurrency) -9. [Error Handling](#error-handling) -10. [Formatting](#formatting) -11. [Comments](#comments) -12. [Translation](#translation) +2. [Strict Mode](#strict-mode) +3. [Variables](#variables) +4. [Functions](#functions) +5. [Objects and Data Structures](#objects-and-data-structures) +6. [Classes](#classes) +7. [SOLID](#solid) +8. [Testing](#testing) +9. [Concurrency](#concurrency) +10. [Error Handling](#error-handling) +11. [Formatting](#formatting) +12. [Comments](#comments) +13. [Translation](#translation) ## Introduction @@ -43,6 +44,33 @@ shaped into its final form. Finally, we chisel away the imperfections when we review it with our peers. Don't beat yourself up for first drafts that need improvement. Beat up the code instead! +## **strict mode** + Strict mode is a special mode that we can activate in JavaScript, which makes it easier for us to write a secure JavaScript code.And all we have to do to activate strict mode is to write this ring at the beginning of the script. + i.e "use strict" +It makes debugging and finding errors in code much easier. + +**Bad:** +``` +let hasDriversLiscense = false; +const passTest = true; + +if(passTest) hasDriverLiscense = true; //error +if(hasDriversLiscense) console.log("I can drive!"); + +``` +**Good:** +``` +'use strict' + +let hasDriversLiscense = false; +const passTest = true; + +if(passTest) hasDriverLiscense = true; //error +if(hasDriversLiscense) console.log("I can drive!"); + +``` +**[⬆ back to top](#table-of-contents)** + ## **Variables** ### Use meaningful and pronounceable variable names From 71f5ce7572b26656ba383907072b0caaa5181d7c Mon Sep 17 00:00:00 2001 From: cksharma2468 Date: Thu, 13 Jul 2023 19:15:16 +0530 Subject: [PATCH 2/2] Strict-mode added updated --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 006542e8..2474d595 100644 --- a/README.md +++ b/README.md @@ -50,16 +50,17 @@ improvement. Beat up the code instead! It makes debugging and finding errors in code much easier. **Bad:** -``` + +```javascript let hasDriversLiscense = false; const passTest = true; if(passTest) hasDriverLiscense = true; //error if(hasDriversLiscense) console.log("I can drive!"); - ``` **Good:** -``` + +```javascript 'use strict' let hasDriversLiscense = false; @@ -67,7 +68,6 @@ const passTest = true; if(passTest) hasDriverLiscense = true; //error if(hasDriversLiscense) console.log("I can drive!"); - ``` **[⬆ back to top](#table-of-contents)**