Drupal 8 Accessing Menu Tree in a Block's JS
The documentation is inevitably focused on PHP, since Drupal is written in PHP and server-side renders.  And the answer to getting info from PHP/server side to JS/client side is not really Drupal specific.  Like any other situation of this ilk in web development, you have two basic choices.  Either annotate your HTML with enough elements, IDs and classes that you can pull the necessary info out of the DOM, or expose an endpoint containing the info in a convenient-for-JS-consumption format like JSON for your javascript to fetch.

As for the latter, if you don't feel like rolling your own endpoint, there seem to be one, two three and maybe more modules, although I cannot vouch for any of them.