title: duplicate the object and then update a value in JSON object
body: <p>I have a array of json objects in jquery . I want to duplicate a object and then replace  key value in original object on the basis of if condition . but every time i replaced the value in single object then it replaced the values in both objects . I only want to replace in one i.e original 
  I have used break and return false statements but dont work.</p>
  
  <pre><code>var index=getIndex(class_id,teacher_id);
  
      finalJson[index]['teacher_name']='asad';
  
  function getIndex(class_id,teacher_id){
      for(var it in finalJson){
      if(finalJson[it]['class'] == class_id &amp;&amp; finalJson[it]['type'] == 'c'){
          finalJson.push(finalJson[it])
          return it;
          }
      }
  }
  </code></pre>
  
  <p>please anybody help here is if condition .
  Thanks in advance. </p>