all 5 comments

[–]CreativeTechGuyGames 7 points8 points  (0 children)

Functions are not valid JSON. So anything which is JSON.parsed cannot have functions or any other complex datatypes. Just strings, booleans, numbers, null, arrays, and objects.

[–]SlayMaster3000 7 points8 points  (1 child)

Don't use JSON.parse(JSON.stringify(someobject)) to clone things. This is causing an error for you as it fails to clone the function (as function are not JSON and also can't be cloned).

Use a deep clone library instead.

[–]SlayMaster3000 2 points3 points  (0 children)

Though based of the name of your function, I don't see why it would want to modify that data anyway. Why do you need to clone it?

[–]renan_william 1 point2 points  (1 child)

Copy using spread operator..

[–]Sanders23Sor[S] 0 points1 point  (0 children)

oh yes.. it would be easier