当前位置:网站首页>Why can't the index of JS array use negative numbers

Why can't the index of JS array use negative numbers

2022-06-23 06:59:00 Tianmiao studio

console.log([][-1]); //undefined  There is no wrong report 

Eliminate the computing out of bounds phenomenon of strongly typed languages

JS Of Array Array is actually a Object, It's not true "Array";

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

 

原网站

版权声明
本文为[Tianmiao studio]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230537090426.html