Add a ton of JS algo snippets (#56)

This commit is contained in:
Yangshun Tay
2017-10-18 17:00:48 +08:00
committed by GitHub
parent d8c3f984e4
commit d9b9d4b5ca
10 changed files with 136 additions and 13 deletions

View File

@ -17,9 +17,8 @@ function deepEqual(val1, val2) {
}
// Object comparison.
if (typeof val1 === 'object' && typeof val2 === 'object') {
const keys1 = Object.keys(val1);
const keys2 = Object.keys(val2);
if (typeof val1 === 'object' && typeof val2 === 'object' && val1 !== null) {
const keys1 = Object.keys(val1), keys2 = Object.keys(val2);
if (keys1.length !== keys2.length) {
return false;
}