Skip to content
Advertisement

Remove and Modify key from object

I have following object

JavaScript

I want to remove is_exchange and replace value of created_at to “2021-03-23” and get back the json representation of the object

I tried like

JavaScript

which is working but

JavaScript

is not working

JavaScript

Advertisement

Answer

To remove a value from an object use the delete method. So, you could do delete obj.payload.is_exchange. And to change a value, just use the = operator. obj.payload.created_at = "2021-03-23".

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement