const a=[1,2]
//const b=a
//above line makes b point to same object in heap as a
To create a copy of a we can write this instead:
const b=a.slice()
// b now contains it's own object [1,2] in heap
Note:slice method is similar(but a little different) to slice operator in python
For ex. unlike slice operator(python), js slice method only accepts 2 arguments.