-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# js的相等性判断 | ||
JavaScript 提供三种不同的值比较运算: | ||
|
||
- ===——严格相等(三个等号) | ||
- ==——宽松相等(两个等号) | ||
- Object.is() | ||
|
||
- IsLooselyEqual:== | ||
- IsStrictlyEqual:=== | ||
- SameValue:Object.is() | ||
- SameValueZero:被许多内置运算使用 | ||
|
||
|
||
# 双等号(==) | ||
|
||
```javascript | ||
const num = 0; | ||
const big = 0n; | ||
const str = "0"; | ||
const obj = new String("0"); | ||
|
||
console.log(num == str); // true | ||
console.log(big == num); // true | ||
console.log(str == big); // true | ||
|
||
console.log(num == obj); // true | ||
console.log(big == obj); // true | ||
console.log(str == obj); // true | ||
``` | ||
|
||
# 三等号(===) | ||
|
||
# Object.is() |