js数组的索引为何不能用负数

console.log([][-1]); //undefined 并没有报错

排除强类型语言的计算越界现象

JS的Array数组实际是个Object,并不是真的"Array";

t arr = [1,2,3,4]
arr[-1] = 'a'
console.log(arr) //[ 1, 2, 3, 4, '-1': 'a' ]

原文地址:https://www.cnblogs.com/tianmiaogongzuoshi/p/14664804.html