-
Notifications
You must be signed in to change notification settings - Fork 0
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
couralex
committed
Dec 13, 2016
1 parent
dce147d
commit a217c1a
Showing
1 changed file
with
14 additions
and
1 deletion.
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 |
---|---|---|
@@ -1 +1,14 @@ | ||
# equal-array | ||
# equal-array | ||
|
||
equal-array compares arrays by values instead of references. | ||
|
||
## Why ? | ||
|
||
It is mainly useful with an es6 Map or Set, where arrays, used as keys, are compared by references. For example : | ||
```js | ||
const map = new Map(); | ||
map.set([1, 2 ,3], 'a'); | ||
map.set([1, 2 ,3], 'b'); // the map will consider [1, 2 ,3] as a new key | ||
map.size(); // returns 2 - with equal-array: returns 1 | ||
map.has([1, 2, 3]); // returns false - with equal-array: returns true | ||
``` |