Skip to content

Commit 46e235d

Browse files
authored
Merge pull request #1 from alieldeba/OmarWebDev-use-identical-not-equals
Use `===` instead of `==`
2 parents 610792d + b1da13b commit 46e235d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,20 @@ var x = 10;
5555
## Explanation
5656

5757
> Yes you can do this. this is called [IIFE](https://developer.mozilla.org/en-US/docs/Glossary/IIFE) it stands for immediately invoked function expression
58+
59+
## Use === instead of ==
60+
61+
```javascript
62+
[10] === 10 // is false
63+
[10] == 10 // is true
64+
'10' == 10 // is true
65+
'10' === 10 // is false
66+
[] == 0 // is true
67+
[] === 0 // is false
68+
'' == false // is true but true == "a" is false
69+
'' === false // is false
70+
```
71+
72+
## Explanation
73+
74+
> The == (or !=) operator performs an automatic type conversion if needed. The === (or !==) operator will not perform any conversion. It compares the value and the type, which could be considered faster than ==.

0 commit comments

Comments
 (0)