It's not pretty, but it works:
const deepCopy = JSON.parse(JSON.stringify(objectToCopy));
?
Itβs a joke man π . I know parse, stringify works. Itβs fast too. Actually, one of my friends got this asked in an interview and thus this article.
I would prefer this all day to that chunky angorithm, is there any reason this is worse?
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It's not pretty, but it works:
?
Itβs a joke man π . I know parse, stringify works. Itβs fast too. Actually, one of my friends got this asked in an interview and thus this article.
I would prefer this all day to that chunky angorithm, is there any reason this is worse?