this programing language make no sense. i just tried store array object in Global and I make function somewhere and get that array > let a = global.get("myobject") somehow the global object is change without calling 'global.set()' > a[0] = "this is annoying" it make debugging process hard to track where node that change global object.
That's because Arrays in JavaScript get passed on as a reference and not by value. This means you don't get the actual values but a pointer referencing the global variable. To solve this you have to make a Deep Copy of the Array. The only way I know of (I don't like it at all) is to use the following syntax. let a = JSON.parse(JSON.stringify(global.get("myobject")); Maybe the following article helps. dev.to/samanthaming/how-to-deep-clone-an-array-in-javascript-3cig
interesting video! Thanks!
Why is it necessary to play music in the background?
It is not necessary - I just like the feel of it, especially for parts without voice over
this programing language make no sense.
i just tried store array object in Global and I make function somewhere and get that array
> let a = global.get("myobject")
somehow the global object is change without calling 'global.set()'
> a[0] = "this is annoying"
it make debugging process hard to track where node that change global object.
That's because Arrays in JavaScript get passed on as a reference and not by value. This means you don't get the actual values but a pointer referencing the global variable. To solve this you have to make a Deep Copy of the Array. The only way I know of (I don't like it at all) is to use the following syntax. let a = JSON.parse(JSON.stringify(global.get("myobject"));
Maybe the following article helps.
dev.to/samanthaming/how-to-deep-clone-an-array-in-javascript-3cig