Dear all,
I am declaring an array 1 and aray 2 as shown below. I am using promise and then block. In the then block I am removing each element from array1 and it is automatically removing elements in array2 as well.
How can I keep array2 same as it is, but I should remove all the elements from array1 in th for loop. Please advice or share your ideas. Thank you for your support and help.
================================================
var arr1=[1,2,3,4];
var arr2=arr1;
var Length=arr1.length
let promise = new Promise(resolve =>{
resolve(arr2);
});
promise.then((result)=>{
for(var i=0;i<Length;i++)
{
arr1.shift();
console.log(arr2);
}
});
================================================