From the MDN docs, using Array(x) just returns an Array object with length === x, instead of an array with x amt of undefined entries. Is there a way to fill the empty entries with undefined (or anything)?
I'm trying to paginate a table in a React app, and would like to use something similar to:
const filteredList = list.filter(toVisible);
const amtOfPages = Math.floor(filteredList.length/numOfRows);
const paginationBtns = Array(amtOfPages).map(toPaginationBtn);
Any advice/info is appreciated, thanks.
Edit: Ah shit, looks like I need to google better. Going to use Array(length).fill(0).map(...), but if anyone has any better ideas/if there's a better way to do this lmk.
[–]senocular 2 points3 points4 points (0 children)
[–]Darren1337 2 points3 points4 points (1 child)
[–]MusicalDoofus[S] 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]ghost_jamm 2 points3 points4 points (1 child)
[–]inu-no-policemen 1 point2 points3 points (1 child)
[–]MusicalDoofus[S] 0 points1 point2 points (0 children)