Skip to content

Instantly share code, notes, and snippets.

@akabab
Created November 2, 2017 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akabab/7a530deb9dc5bc0e700ce682b310244d to your computer and use it in GitHub Desktop.
Save akabab/7a530deb9dc5bc0e700ce682b310244d to your computer and use it in GitHub Desktop.
// 2d Arrays
const Array2d = (w, h = w, fillWith = undefined) =>
Array(h).fill(fillWith).map(e => e = Array(w).fill(fillWith))
// 2D array fill of 0
Array(10).fill(0).map(e => e = Array(10).fill(0))
// ->
Array2d(10, 10, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment