This is a common source of confusion for beginners (myself included). You can find related threads about it. One nice answer is this one:
lmiq
2
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Assignment and mutation | 6 | 7052 | December 31, 2018 | |
| What is the philosophy behind arrays not being copied when assigned to another variable? | 24 | 2712 | May 19, 2023 | |
| Array assignment is alias and assignment semantics | 7 | 1002 | April 7, 2021 | |
| Assignment of array elements | 2 | 5334 | February 1, 2018 | |
| When will the original value be changed with the copied value? | 8 | 1647 | April 21, 2020 |