Created
May 13, 2021 06:54
-
-
Save muzi131313/435292629bce9f9d191d887d941f7d9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function includeKey(objectA, objectB) { | |
if (!objectA || !objectB) { | |
return false; | |
} | |
const objectAKeys = Object.keys(objectA); | |
const objectBKeys = Object.keys(objectB); | |
if (!objectBKeys || !objectBKeys) { | |
return false; | |
} | |
const _include = objectBKeys.some(objectBKey => { | |
return objectAKeys.includes(objectBKey) | |
}) | |
return _include; | |
} | |
console.log(includeKey({a: 123, b: 33}, {a: 33})); // true | |
console.log(includeKey({a: 123, b: 33}, {c: 33})); // false | |
console.log(includeKey({a: 123, b: 33}, {})); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment