Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Create object from another one Javascript

I have an object {key: ‘Mother’, value: ‘Mam’}.
I need to get an object like {‘Mother’: ‘Mam’}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Your question is pretty vague but you could do:

const obj1 = {key: 'Mother', value: 'Mam'}
const obj2 = {[obj1.key]: obj1.value}

// obj2: {Mother: 'Mam'}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading