Exam4Training

Which two lines of code result in a second array, arr2 being created such that arr2 is not a reference to arr1?

Refer to the following array:

Let arr1 = [ 1,2, 3, 4, 5 ];

Which two lines of code result in a second array, arr2 being created such that arr2 is not a reference to arr1?
A . Let arr2 = arr1.slice(0, 5);
B . Let arr2 = Array.from(arr1);
C . Let arr2 = arr1;
D . Let arr2 = arr1.sort();

Answer: A,B

Exit mobile version