How to Swap Key and Value in Object in Javascript - Challenge #3

preview_player
Показать описание
This is another basic javascript challenge for beginners. The challenge here is to swtich key and value of properties in an object.
Рекомендации по теме
Комментарии
Автор

Great walk through explanation! Thank you

alfonsoramirezelorriaga
Автор

thank you. it is a very simple and understandable approach

rakeshthottathil
Автор

You can easily swap keys and values by creating a new object using a one-liner.

Lets assume that we have an object, whose keys and values should be exchanged.
let originalObject = {"key": "value"};

Then we can create another object with swapped keys and values:
let swappedObject = => v.reverse()));

adrianzinke
Автор

Nice, but how you would do it if it's a nested object?

alexandrustan
join shbcf.ru