How do I format JQuery in Drupal 8? I'm trying to write a simple JQuery function in order to animate my mobile navigation. However, I'm not sure how to format the .js file. I've looked up some examples online, but I couldn't get my function to work, when I tried to use the example templates. Here's what I'm currently using, which works in Chrome, but FireFox logs an error, which I'll also post below:

My code:

(function ($, Drupal) {
      $(function(){
        $( '#mobile-menu-toggle-button' ).click(function(){
          $( '.mobile-menu-toggle' ).toggleClass( "open" );
        });
        $( '.overlay' ).click(function(e){
          if(e.target != this) return;
          $( '.mobile-menu-toggle' ).toggleClass( "open" );
        });
      });
})(jQuery, Drupal);


FireFox errors:

ReferenceError: Drupal is not defined


I'm thinking my formatting is off. Any help would be greatly appreciated.
D8 makes fewer assumptions about what you need in the page, so the Drupal JS library isn't included unless it's specified.

Just add

- core/drupal


as one of your library's dependancies, rebuild the cache, and all should be well.