Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ok, so when i do array=array2 then change something in array2 it changes array. how do i prevent this?
Do..
b = a.slice()
Why? Because assignment would just reference the origin object. slice or concat would create a new object.
slice
concat
Add a comment
var b = a.concat();
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.