0

1st way:

number= [{},{}];
numberCopy= number;

2nd way :

number= [{},{}];
numberCopy= [...number];
  • 2
    Does this answer your question? [What is the difference between a shallow copy and a deep copy with JavaScript arrays?](https://stackoverflow.com/questions/24512712/what-is-the-difference-between-a-shallow-copy-and-a-deep-copy-with-javascript-ar) – kmoser Jun 11 '20 at 11:40
  • @mplungjan This question is not a duplicate of the one you set. OP is asking a question about pointer assignment and a shallow copy, not the difference between a deep and a shallow copy – Seblor Jun 11 '20 at 12:22
  • 1
    the code would not work anyway. the dupe explains all there is to know about assignment deep copy and shallow copy. There is not much else to be learned from this question - I can add more dupes if you are not happy – mplungjan Jun 11 '20 at 12:24
  • @mplungjan I agree that this question is a duplicate. However, as it seems OP is not used to StackOverflow, I think choosing a question closer to OP's is more appropriate, like this one : https://stackoverflow.com/questions/26745170/javascript-array-assign-issue – Seblor Jun 11 '20 at 12:27
  • 1
    So we add it to the list – mplungjan Jun 11 '20 at 12:27
  • 1
    @Seblor Member of SO for 6 years – mplungjan Jun 11 '20 at 12:28

0 Answers0