title: How do I create a new object from an existing object in Javascript?
body: <p>Working on JavaScript app and need help in <strong>creating a new object from response received from ajax call.</strong></p>
  
  <p>The output received is array of objects, sample format below: </p>
  
  <pre><code>{
    "items": [
      {
        "id": "02egnc0eo7qk53e9nh7igq6d48",
        "summary": "Learn to swim",
        "start": {
          "dateTime": "2017-03-04T19:00:00+05:30"
        }
      }        
  
  ]
  }
  </code></pre>
  
  <p>However, my component expects JS Object in the following format:</p>
  
  <pre><code>{
  id: "e1",
  title: "Express",
  start: "Jan 13, 2010",
  description: "Jan 13, 2010"
  }
  </code></pre>
  
  <p>Is following approach correct, please suggest better approach if any</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var content = {
      "items": [{
          "id": "02egnc0eo7qk53e9nh7igq6d48",
          "summary": "Learn to code",
          "start": {
            "dateTime": "2017-03-04T19:00:00+05:30"
          }
        }
        }
      };
      var gcalEvents = {};
      var jsonObj = {
        "id": "e1",
        "title": "Oracle Application Express",
        "start": "Jan 13, 2010",
        "description": "Jan 13, 2010"
      };
  
      console.log(content.items.length);
      for (var index = 0; index &lt; content.items.length; index++) {
        var obj = content.items;
        console.log(obj);
  
        jsonObj.id = obj[index]["id"];
        jsonObj.title = obj[index].summary;
        jsonObj.start = obj[index].start.dateTime;
        jsonObj.description = "";
        console.log(jsonObj);
        gcalEvents[index] = jsonObj;
      }
      console.log(gcalEvents);</code></pre>
  </div>
  </div>
  </p>