Menu Details Output in Javascript [closed]

You can just use wp_get_nav_menu_items( $menu, $args ); to get list of menu items created in appearance.

You can print result the way you want. Before printing just make sure the datas are not empty and so. I didn’t add any validation. So use according to your need.

For example:

We’ll try to print the data at wp_head

add_action('wp_head','menu_to_js');
function menu_to_js(){
  $locations = get_nav_menu_locations();
  $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );//$menu_name should be your menu name
  $menu_items = wp_get_nav_menu_items($menu->term_id);
  $menu_items = json_encode($menu_items);

  //So now we have json encoded $menu_items, put that in javascript 
   ?>
      <script>
       var menu_itemss = "<?php echo $menu_items; ?>";
       //now manipulate in js and use the way you want.
      </script> 
    <?php
   }