title: javascript objects: getting data from object property
body: <p>I have problem with returning the value of object property</p>
  
  <pre><code>function Obj() {
  this.objects =
          [
              {
                  id: 0,
                  values: {
                      x: 10,
                      y: 10
                  }
              },
              {
                  id: 1,
                  values: {
                      x: 15,
                      y: 20
                  }
              }
          ];
      }
  Obj.prototype.getOjects = function() {
      return this.objects;
  };
  Obj.prototype.getModifiedOjects = function() {
      var i, obj;
      obj = this.getOjects();
  
      for(i=0; i&lt;obj.length; i++ ){
          obj[i].values.x *= 2;
          obj[i].values.y *= 2;
      }
      return obj;
  };
  
  var obj = new Obj(), modifiedObjects;
  console.log(obj.getOjects()); // value of 0 =&gt; {x =&gt; 10, y: 10}, 1 =&gt; {x =&gt; 15, y: 30}
  modifiedObjects = obj.getModifiedOjects(); // Do something with mofified objects
  console.log(obj.getOjects()); // value of 0 =&gt; {x =&gt; 20, y: 20}, 1 =&gt; {x =&gt; 30, y: 40}
  </code></pre>
  
  <p>When I call the <strong>getModifiedOjects</strong> function, also change the values of <strong>objects</strong> property.</p>
  
  <p>How to make the <strong>getOjects</strong> function to not return object property by reference?</p>
  
  <p>Thanks.</p>