Skip to content

Commit acbf60c

Browse files
authored
Update README.md
1 parent 07b93a0 commit acbf60c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,17 @@ if(a === b) return true
595595
596596
Then comes the interesting part! There are several data types we need to look out for: Objects, Arrays(which JS treats as an object), and Dates(which is also treated as an object!), thus all we have to do is check if both a and b are of type object. If not, we can just return false as they didn't pass the ```a === b``` test.
597597
598-
```js if(typeof a === "object" && typeof b === "object")...```
598+
```js
599+
if(typeof a === "object" && typeof b === "object")...
600+
```
599601
600602
Note that we use ```===``` here to differentiate between data types strictly.
601603
602604
Next, we can process the dates first, as that doesn't require iteration. Make sure to compare ```Date.valueOf()``` instead of the date object itself.
603605
604-
```js if(a instanceof Date && b instanceof Date) return a.valueOf() === b.valueOf() ```
606+
```js
607+
if(a instanceof Date && b instanceof Date) return a.valueOf() === b.valueOf()
608+
```
605609
606610
Lastly, by taking the keys of the iterables we can compare the length of ```a``` and ```b```, then make use of built-in Array.some method to check if any values of the two iterables don't match.
607611

0 commit comments

Comments
 (0)