0

why an error is not shown, when I try to add new elements in the array, using negative indexing.

var myArray = new Array(3);
myArray[0] = 0;
myArray[1] = 1;
myArray[2] = 2;

myArray[-1] = -1;

console.log(myArray);

I was expecting an Error,But instead I get a output like this.

enter image description here

0 Answers0