negative indexing in arrays javascript code example
Example: negative indexing in arrays javascript
// 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