var arr=test; arr.splice(2,1); alert(test);//1,2,4,5,6,7
JS arrays are essentially objects. Therefore, the above source code finally prints 1,2,3,4,5,6. This is because assigning test to arr actually assigns the reference of the array to arr, so operating arr will also
Change the source array.
To implement array cloning, the following methods can be used:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn