Created
June 4, 2024 06:27
-
-
Save sukeharu/45a51e0f96f57f606e83834988750feb to your computer and use it in GitHub Desktop.
オブジェクト全体ではなく、プロパティを結合することも可能
This file contains 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
// オブジェクトのプロパティを結合することも可能 | |
const withProp1 = { | |
n: 1, | |
o: { | |
prop1: 'p1', | |
prop2: 'p2', | |
}, | |
}; | |
const withProp2 = { | |
n: 1, | |
o: { | |
prop3: 'p3', | |
prop4: 'p4', | |
}, | |
}; | |
const concatProps = { | |
...withProp1.o, | |
...withProp2.o, | |
}; | |
console.log(concatProps); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment