📌  相关文章
📜  数组中的负索引 javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:35.035000             🧑  作者: Mango

代码示例1
// javascript allows negative indexing but not same way as in python
const check = ["orange", "banana", "apple"]
// console.log(check[-1]) //returns an error
check[-1] = "negative fruit"
console.log(check) // ["orange", "banana", "apple", -1: "negative fruit"]
console.log(check[-1]) //returns "negative fruit"
// so it creates a key-value pair