Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add strict-mode❗ for cleaner code #436

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 39 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:**

```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;
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
Expand Down