Recently, when writing code, I often encounter js variable assignment pointing to the same memory. Is there any way to avoid this problem?

recently, when writing code, I often encounter js variable assignment pointing to the same memory. Is there any way to avoid this problem?

Apr.04,2021

JavaScipt generally has three scalar types:: string (string, number (number), and boolean (Boolean). Reference types, object, array, and so on. Two special types: null and undefined.

The

scalar type assignment is a copy of copy, and then the assignment. The reference type points to the same memory.

usually there are more array and object assignments, which point to the same memory.


you can solve the problem by reading a good book and improving your knowledge.


immutable.js
but I don't think you'll have a problem with this. Your main problem is still too lame.


Let's code something. Since when can js operate memory? You didn't learn the reference type well.

Menu