Search code examples
javascriptgoogle-closure-library

Is there a utility to deeply compare objects in Google Closure Library?


I hope there is such tool in this big library. But I can't find it.

Offtopic: is there a nice feature list for GCL in the net?


Solution

  • If you don't really care for performance, you can do a deep value comparison with a little JSON magic.

    function isEqual(objA, objB) {
        return goog.json.serialize(objA) === goog.json.serialize(objB);
    }