Trails Packages
    Preparing search index...

    Function shallowEqual

    • Compares two values using shallow equality.

      This is useful when you want to detect changes on the top level without recursively traversing nested objects.

      Primitive values are compared by value. Arrays and objects are compared by their own enumerable keys, but nested values are only compared by reference. Circular objects are not supported.

      NOTE: This function is intended to be used with plain old data inputs (i.e. mostly JSON).

      Examples:

      shallowEqual({ a: 1 }, { a: 1 }); // true
      shallowEqual({ a: { x: 1 } }, { a: { x: 1 } }); // false
      shallowEqual([1, 2], [1, 2]); // true
      shallowEqual(() => 1, () => 1); // false

      Parameters

      • a: unknown
      • b: unknown

      Returns boolean