The following code: difference(prevState.sources, this.state.sources) === []
returns false
even though difference()
returns an empty array. Why is this and how do I fix it?
Asked
Active
Viewed 39 times
0
-
5correct ... because an object is only equal to itself, not another object ... try `difference(prevState.sources, this.state.sources).length === 0` instead ... the fact that `[] !== []` has been discussed in numerous questions on stack overflow - I understand it may be difficult to search such a thing – Jaromanda X Dec 17 '18 at 23:52
-
2Returns an empty array, but they are on different memory location – ahmet_y Dec 17 '18 at 23:58