)
}
}
)
(
}
{
)
)
(
)
(
(
{
}
)
(
)
}
)
)
{
(
(
)
)
}
)
(
}

Array.at Negative Indices

  1. const arr = [
  2.   'one', 'two', 
  3.   'three', 'four'
  4. ];
  5. console.log(
  6.   arr.at(-1), 
  7.   arr.at(-2), 
  8.   arr.at(0)
  9. );

Array.at allows negative index values to be used to read elements from an array. I’ve seen this done using a Proxy in the past.

snippet.zone ~ 2021-24 /// {s/z}