Skip to content

Instantly share code, notes, and snippets.

@sartak
Last active May 18, 2019 17:57
Show Gist options
  • Save sartak/9441c244ce7ca46fc3eb96eb3a71053f to your computer and use it in GitHub Desktop.
Save sartak/9441c244ce7ca46fc3eb96eb3a71053f to your computer and use it in GitHub Desktop.
[].__proto__.__proto__ = new Proxy({}, { get: (_, n) => n < 0 ? [] : [...[][n-1], n] })
// Proxy {}
[][5]
// (6) ["0", "1", "2", "3", "4", "5"]
[][42]
// (43) ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42"]
CC0 1.0 Universal
To the extent possible under law, Shawn M Moore has waived all copyright and
related or neighboring rights to [].js.
Definitely feel free to use this in production.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment