mybearworld
loading
I'd argue JS's behavior makes more sense in this case. Compare:
>>> a = [[1,2,3,4]] >>> b = [1,2,3,4] >>> b in a True >>> b.append(5) >>> b in a False >>> # so b isn't _actually_ in a! >>> >>> c = [b] >>> b in c True >>> b.append(6) >>> b in c True >>> # but b actually _is_ in c. >>> # however, before appending `b in a` and `b in c` are the same.
> let a = [[1,2,3,4]] undefined > let b = [1,2,3,4] undefined > a.includes(b) false > b.push(5) 5 > a.includes(b) false > // b isn't in a, and we know that from the beginning undefined > > let c = [b] undefined > c.includes(b) true > b.push(6) 6 > c.includes(b) true > // and b _is_ in c, which we also know from the beginning undefined