functiondeepEqual(a, b) {// check if `value` is (non-function) objectfunctionisNonFunctionObject(value) {returntypeof value ==='object'&& value !==null; }// 1. same value -> always equalif (a === b) returntrue;// 2. a !== b// 2.1 (either one is primitive/function) different values -> always unequalif(!isNonFunctionObject(a) ||!isNonFunctionObject(b)) returnfalse;// 2.2 both (non-function, different) objects// - count propertiesconstkeysA=Object.keys(a),keysB=Object.keys(b);if (keysA.length!==keysB.length) returnfalse;// - check property keys/valuesfor (constkeyof keysA) {if (!keysB.includes(key) ||!deepEqual(a[key], b[key])) returnfalse; }// - property keys/values all matchreturntrue;}