deep clone using JSON.parse/stringify only when the value is not a primitive