Skip to content

Instantly share code, notes, and snippets.

View kevinbarabash's full-sized avatar

Kevin Barabash kevinbarabash

  • Khan Academy
  • Montreal
View GitHub Profile
@kevinbarabash
kevinbarabash / proxied-array.js
Created June 27, 2023 03:23
Proxied Array to enabled negative indices on arrays in JavaScript
const arrayInstanceHandler = {
get(target, property, receiver) {
if (property < 0) {
property = target.length + parseInt(property);
}
return target[property];
},
};
const arrayConstructorHandler = {