Proxy() instance has its own identity different from all other
Proxy() objects and from the object proxied. When applied to two objects, he equality operators
=== compare the object references, and the consequence is that:
- Comparing distinct proxies returns false even though the underlying target is the same.
- An unwrapped target object is not equal to any of its proxies.
You are witnessing a known technological limitation. Alternatives have been suggested such as the implementation of proxy-aware equality functions like
Proxy.isIdentical() to replace all uses of
=== respectively, but this makes the code less portable because you have to modify the application.
Could I can suggest this as a workaround? Use
JSON.stringnifY() which could have some benefits:
var array1 = [1,2,3];
var array2 = [1,2,3];
var F = JSON.stringify;
array1 == array2, //returns false
array1 === array2, //returns false
F(array1) === F(array2), //returns true
F(cmp.get('v.array1')) === F(cmp.get('v.array2')) //returns true;
As you can see, you can enable identity based on the content of the object, no matter its origin. While
array2 have the same content, they are not identical.
Maybe comparing the content is more desirable in your app?