Skip to content

Instantly share code, notes, and snippets.

@ThomasKruegl
Created April 6, 2021 15:11
Show Gist options
  • Save ThomasKruegl/a775417974820dbf51f41b84e446367e to your computer and use it in GitHub Desktop.
Save ThomasKruegl/a775417974820dbf51f41b84e446367e to your computer and use it in GitHub Desktop.
function getNestedArr(depth) {
const result = [0, null];
let inner = result;
for (let i = 1; i < depth; i++) {
const next = [i, null];
inner[1] = next;
inner = next;
}
return result;
}
console.log(JSON.stringify(getNestedArr(10000)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment