deepEqual throws exception (#122)

If deepEqual is invoked with an empty object and null, it throws TypeError.
This commit is contained in:
Deniz Susman
2019-04-03 19:18:00 +03:00
committed by Louie Tan
parent 765f880e00
commit 1e088e7226

View File

@@ -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;