I've tried lots of solution that I've found in here, but until now any of them really solved my problem.
Let's say that I have a function like this:
var SquareObject = function(id, x, y, text, rectClass, textClass){
var arrayObj = {
"id": null,
"shape": "rect",
"label": null,
"rect": {
"class": null,
"x": null,
"y": null,
...
},
"text": {
"class": null,
"x": null,
"y": null,
...
}
function initArrayObj(){
...
}
function anotherFunction(){
...
}
}
How can I copy everything, including the methods? Because after I make a copy of this SquareObject I'll have to change the properties located at arrayObj, while still maintaining a copy of its original state.
I've found ways of cloning just the content of arrayObj, but right now that doesn't fully solve my problem.
Thanks!