Created
April 16, 2020 15:23
-
-
Save ohhskar/7cb8485222d1df74712a06f88e710c01 to your computer and use it in GitHub Desktop.
Flatten the children of two or more NodeLists into an array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Magic code to flatten the children of two or more nodelists. | |
// [...sides] converts the two nodelists into two arrays. this is then | |
// mapped to get the children. [...element.children] gets the children of each | |
// side, but in the form of an array. This is done so that there will be n arrays | |
// that is composed of the children, this is then flattened | |
const getChildren = (sides) => [...sides].map((element) => [...element.children]).flat(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment