Consider the following code snippet: using the splice method, a specific item from Array1 is retrieved and stored in a variable called Popped. Next, Popped is added to array2. However, if we then delete the value from Popped, why does array2 become undefined even though the value was previously pushed into it?
let Array1 = [
{id: 1, name: "APPLES"},
{id: 2, name: "ORANGE"},
{id: 3, name: "PEAR"},
{id: 4, name: "MANGO"}];
let array2 = [];
let popped = Array1.splice(0, 1)
array2.push(popped);
console.log("Array2: ", array2[0][0].name)
document.querySelector("#First").innerHTML = "First: " + array2[0][0].name;
delete popped[0]; //why when we delete popped, value is undefined ?
document.querySelector("#Second").innerHTML = "Second: " + array2[0][0].name; // undefined