Created
March 15, 2018 00:31
-
-
Save TheAlchemist64/4a60f8c5dcdb832994d1769f7bf9f26d to your computer and use it in GitHub Desktop.
This is a recursive JS function that checks if a property is shared between N number of objects. Uses rest parameters.
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
import sharedProp from './sharedProp.js'; | |
let a = {a:1,b:2}; | |
let b = {a:3,c:4}; | |
let c = {a:5, d:6}; | |
console.log(sharedProp('a')); | |
console.log(sharedProp('a', a)); | |
console.log(sharedProp('a', b)); | |
console.log(sharedProp('a', c)); | |
console.log(sharedProp('a', a, b)); | |
console.log(sharedProp('a', b, c)); | |
console.log(sharedProp('a', a, c)); | |
console.log(sharedProp('a', a, b, c)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment