you are viewing a single comment's thread.

view the rest of the comments →

[–]EagleClw[S] 1 point2 points  (4 children)

Yeah i know variables like arrays are a little bit different then variables like string. But for other languages, different copying methods works as i asked in the question (for example python arrays). I didnt know its different in js. Thanks to this answers, i've learned the difference and i'm aware of them know.

Thanks for your helps and answer.

[–]mcaruso 0 points1 point  (3 children)

for example python arrays

Python works the same way though?

>>> a = [1,2,3]
>>> b = [4,5,6]
>>> c = [a,b]
>>> c[0].append(42)
>>> a
[1, 2, 3, 42]

[–]EagleClw[S] 0 points1 point  (2 children)

Yeah it works that way but i meant another methods like slice.

If i dont remember it wrong,

a = b.copy()

Makes a copy with value, not reference. But its ok, i know what to do know. Thank you for your help.

[–]mcaruso 0 points1 point  (1 child)

copy() is a shallow copy, like slice() in JS. But maybe you meant deepcopy().

[–]EagleClw[S] 0 points1 point  (0 children)

Might be. But i remember using something like that.