Knowledge Walls
John Peter
Pune, Maharashtra, India
How to clone or copy Object in Javascript with Example
2221 Views
HTML
<div><b>How to clone or copy Object in Javascript with Example</b></div>
<br />
JAVASCRIPT
var dataObject = new Array();
    dataObject.push("Raja");
    dataObject.push("Kumar");
    dataObject.push("Siva");

var copyObject = JSON.parse(JSON.stringify(dataObject));
    copyObject.push("Sarathy");

document.write(dataObject+"<br />");
document.write(copyObject+"<br />");
Demo & Output 
Best Lessons of "Good Javascript Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details