<@U8CT0V220> Actually according to some article I ...
# suitescript
a
@jkabot Actually according to some article I read some time ago which I can't find now, one of the best ways to make an object copy is using
JSON.parse()
and
JSON.stringify
...
a
Found this link that says that stringify and parse is good enough for a simple JSON object: https://we-are.bookmyshow.com/understanding-deep-and-shallow-copy-in-javascript-13438bad941c
👍 1
s
the idiomatic way to copy an object in 2019 is probably
Copy code
let newobj = { ...oldobj }
j
I usually use spread too, but to be fair I think it only clones "one level deep"
s
aye
JSON.stringify() doesn't walk the prototype chain either... so only owned props get serialized.