I can't copy the array
arrays, javascript, web
Solution
Arrays are objects, unlike the primitive types like string, int, etc ... variables that take objects correspond to references (pointer) for objects, rather than the object itself, so different variables can reference the same object. Variable of primitive type (string, int, etc.) are associated to values.
In your case you will have to clone your object array for have the same values.
var Mycollection = new Array("James", "John", "Mary");
var Mycollection2 = Mycollection.slice();
Problem
I can't copy the array. ``` var Mycollection = new Array("James", "John", "Mary"); var Mycollection2 = Mycollection; ``` Any change made in the first array is also taken in the second. ``` Mycollection.pop(); console.log(Mycollection.toString()) // ["James", "John"] console.log(Mycollection2.toString())// ["James", "John"] ``` However, this does not occur when I use variables of text type.