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

bad of loose equality & good of strict equality added #456

Open
wants to merge 1 commit 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -974,6 +974,34 @@ function combine(val1, val2) {

**[⬆ back to top](#table-of-contents)**

### Strict Equality & Loose Equality (part 3)

Use non-strict comparison operators, and then comparing across different types. The bad example did not provide expected results for using non-strict comparison operators (==). It only compare between values, but not with identical. So, To get our expected output we have to use ‘===’ instead of ‘==’, for instance.

**Bad:**

```javascript
1 == “1”; // true
0 == false; // true
null == undefined; // true
[] == false // true
1 == true // true
"" == 0 // true
```

**Good:**

```javascript
1 === “1”; // false
0 === false; // false
null === undefined; // false
[] === false // false
1 === true // false
"" === 0 // false
```

**[⬆ back to top](#table-of-contents)**

### Don't over-optimize

Modern browsers do a lot of optimization under-the-hood at runtime. A lot of