I am trying to clone the object props.messages.serverError; I tried the following three methods individually:
1. let serverError= {...props.messages.serverError};
2. let serverError = Object.assign({}, props.messages.serverError);
3. let serverError= JSON.parse(JSON.stringify(props.messages.serverError}));
After cloning the object I set the original object to null then log the cloned object a as follows:
props.messages.serverError = null;
console.log('serverError', serverError)
serverError is also null instead of the original value even though it is now supposed to occupy a memory address different from the original object due to the cloning.