From 0ea48f27e2a8b9dbe3c10ea2cffd06a33befc85c Mon Sep 17 00:00:00 2001 From: Deniz Susman Date: Wed, 3 Apr 2019 18:45:07 +0300 Subject: [PATCH] deepEqual throws exception If deepEqual is invoked with an empty object and null, it throws TypeError. --- utilities/javascript/deepEqual.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/javascript/deepEqual.js b/utilities/javascript/deepEqual.js index ec82255c..d2c9f649 100644 --- a/utilities/javascript/deepEqual.js +++ b/utilities/javascript/deepEqual.js @@ -17,7 +17,7 @@ function deepEqual(val1, val2) { } // Object comparison. - if (typeof val1 === 'object' && typeof val2 === 'object' && val1 !== null) { + if (typeof val1 === 'object' && typeof val2 === 'object' && val1 !== null && val2 !== null) { const keys1 = Object.keys(val1), keys2 = Object.keys(val2); if (keys1.length !== keys2.length) { return false;