Skip to content
Advertisement

Why is this array changing when I’m not operating on it?

I have two arrays:

JavaScript

And I’m running the foll)owing code:

JavaScript

I get the following result:

JavaScript

Why are the last elements changed? I don’t see why X is changed by indexing some elements.

edit: added np.array

Advertisement

Answer

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement