stack

Home > @infiniteobjects/core-library-web > Obj > diff

Obj.diff() method

Returns an object containing all elements that differ between two objects.

It works best when object2 originated by deep copying object1, then changes were made to object2, and you want an object that would give you the changes made to object1 which resulted in object2.

Signature:

static diff<T = ObjectLike>(object1: T | any, object2: PartialDeep<T> | any, depth?: number): PartialDeep<T>;

Parameters

Parameter Type Description
object1 T | any The base object to compare to
object2 PartialDeep<T> | any The object to compare with
depth number (Optional) An optional depth to prevent recursion. Default: 20.

Returns:

PartialDeep<T>

A differential object, which if extended onto object1 would result in object2.