Smarter way to loop through all existing artboards?

How could I directly loop through all the artboards without using a conditional statement as shown below? Also how do I get the total number of artboards? (something like artboards.length)

  rootNode.children.forEach((node) => {

    if (node instanceof Artboard) {