Home Tutorialhelp Allcomments Java Javascript Array Array Clone

 
 

Comments

 
User Comments for the tutorial:

JavaScript Array Clone



Total comments: 2      View Tutorial    Discuss: JavaScript Array Clone
Advertisement
Comments

Similar implementation
var originalJSONObj = this.jsonPanelData.fieldList; //fieldList is the json object being passed from server side var clonedJSONObj = this.deepCloneJSON(originalJSONObj); //clonedJSONObj is the cloned object deepCloneJSON: function(obj) { var o 

You would obtain the same with splice
Array.prototype.clone = function() { return this.splice(0); } Except that not all objects have a clone method, so actually I think the use of splice might be less error prone :) 

Related Tutorial and Articles
Advertisements Advertisements
 

 

 

DMCA.com