0

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?

isherwood
  • 58,414
  • 16
  • 114
  • 157
Foobar
  • 7,458
  • 16
  • 81
  • 161
  • 5
    correct ... 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
  • 2
    Returns an empty array, but they are on different memory location – ahmet_y Dec 17 '18 at 23:58

0 Answers0