title: Using spread operator to update an object value
body: <p>I have a function which adds a key to incoming object, but I have been told to use spread operator for that, I have been told that I can use the spread operator to create a new object with the same properties and then set isAvailable on it.</p>
  <pre><code>  return new Partner(ServerConfig, capabilities, initialState)
  }
  
  class Partner {
    constructor (ServerConfig, capabilities, initialState) {
      initialState.isAvailable = true
  </code></pre>
  <p>So I tried something like this but coulndt succeed, can you help me ? and confused, should I use spread operator in this way , return from a function ?</p>
  <pre><code>newObject = {}
  
  // use this inside a function and get value from return
  
         return {
           value: {
             ...newObject,
             ...initialState
           }
         }
  
  initialState.isAvailable = true
  </code></pre>