js delete object in dict 1

js delete object in dict

delete myArray[id_to_remove];

Here is what the above code is Doing:
1. We create an array with three elements.
2. We create a variable called id_to_remove and assign it the value of 1.
3. We delete the element with the index of 1.
4. We print the array to the console.

The output of the above code will be:

[1, undefined × 1]

Notice that the element with the index of 1 is gone.

Instructions
1.
Delete the element with the index of 2 in myArray.

Similar Posts