My global variable is changing itself

var some =[‘sonething’,‘blabal’];

function add()
var some1 =some;
some1 =[‘changed’,’ it’];

This somehow changes my global variable.
i don’t understand why it is happening

This sounds like an issue with how arrays are stored in JavaScript. You can search a little bit on google about this.

I found this article. From the initial example, it looks like it will explain the issue, though I’m not sure how intuitive the explanation will be. If you don’t find it helpful, hopefully it will help you learn more about the issue and you can search for a more helpful article.

Perhaps you have noticed that if you assign an array to another variable and modify that variable’s array elements, the original array is also modified. Or perhaps you have passed an array to a function hoping to modify only the local copy of the array, but you find that the original array has also been modified. This happens because arrays are reference types in JavaScript.

That means that if you assign an array to a variable or pass an array to a function, it is the reference to the original array that is copied or passed, not the value of the array.