Shallow equality checks across Object and Array #3107
-
Bug DescriptionHey, I noticed some surprising behavior with the shallow function. Objects and arrays are equal when they have the same key and value pairs. Is this expected? import { shallow } from 'zustand/vanilla/shallow';
const obj = { 0: 'foo', 1: 'bar' };
const arr = ['foo', 'bar'];
shallow<any>(obj, arr); //true Reproduction Linkhttps://stackblitz.com/edit/vitejs-vite-jh8zrgef?file=src%2FApp.tsx |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
@steaks nice catch |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
One could argue that the current behavior is correct. Javascript is a funny language. Both are |
Beta Was this translation helpful? Give feedback.
@steaks here you go -> #3108