{"ScriptPreparationCode":"function deepEqual(obj1, obj2){\r\n\r\n // Initialisation\r\n let obj1Keys = Object.keys(obj1);\r\n let obj2Keys = Object.keys(obj2);\r\n\r\n // Compare le nombre de propri\u00E9t\u00E9s\r\n if(obj1Keys.length != obj2Keys.length)\r\n return false;\r\n\r\n // Compare le nom des cl\u00E9s de chaque propri\u00E9t\u00E9\r\n let set = new Set([...obj1Keys, ...obj2Keys]);\r\n if(set.size != obj1Keys.length)\r\n return false;\r\n\r\n // Compare les valeurs\r\n {\r\n // Compare le type de chaque valeur\r\n let objValues = obj1Keys.map(key =\u003E[obj1[key], obj2[key]])\r\n let sameType = objValues.every( value =\u003E typeof value[0] === typeof value[1]);\r\n if(!sameType)\r\n return false;\r\n\r\n // Compare directement les valeurs\r\n let valueTypes = [\u0027number\u0027, \u0027string\u0027, \u0027boolean\u0027, \u0027symbol\u0027, \u0027undefined\u0027, \u0027bigint\u0027];\r\n let allTypes = [...valueTypes, \u0027null\u0027, \u0027object\u0027];\r\n\r\n // On trie le tableau pour comparer en priorit\u00E9 les types valeurs, puis les types r\u00E9f\u00E9rences (qui impliquent une r\u00E9cursion)\r\n let objValuesTypeSorted = objValues.sort((a, b) =\u003E allTypes.indexOf(typeof a[0]) - allTypes.indexOf(typeof b[0]));\r\n // On utilise every() pour sortir de la m\u00E9thode d\u00E8s qu\u0027une diff\u00E9rence est relev\u00E9e\r\n var sameValues = objValuesTypeSorted.every(values =\u003E {\r\n // Compare les types valeurs\r\n if(valueTypes.includes(typeof values[0]))\r\n return values[0] === values[1];\r\n\r\n // Compare les types objets\r\n else {\r\n if (values[0] === null \u0026\u0026 values[1] === null)\r\n return true;\r\n else if(values[0] === null \u0026\u0026 values[1] !== null || values[1] === null \u0026\u0026 values[0] !== null)\r\n return false;\r\n else\r\n return deepEqual(values[0], values[1]);\r\n }\r\n })\r\n }\r\n\r\n if(!sameValues)\r\n return false;\r\n return true;\r\n}\r\n\r\n// 1 level deep\r\nwindow.foo1 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } };\r\nwindow.bar1 = { a: 1, b: 3, c: { a: 1, b: 2, c: { a: 1, b: 2 } } };\r\n\r\n// 2 levels deep\r\nwindow.foo2 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } };\r\nwindow.bar2 = { a: 1, b: 2, c: { a: 1, b: 3, c: { a: 1, b: 2 } } };\r\n\r\n// 3 levels deep\r\nwindow.foo3 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } };\r\nwindow.bar3 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 4 } } };","TestCases":[{"Name":"lodash","Code":"_.isEqual(window.foo1, window.bar1)","IsDeferred":false},{"Name":"custom-deepEqual","Code":"deepEqual(window.foo1, window.bar1);","IsDeferred":false},{"Name":"JSON.stringify()","Code":"JSON.stringify(window.foo1) === JSON.stringify(window.bar1);","IsDeferred":false}]}