JavaScript dependencies for a specific block or page
Define an asset library in mymodule.libraries.yml. An asset library can declare either CSS assets or JavaScript assets, or both. It can also declare dependencies on other asset libraries. For example on jQuery (core/jquery) or perhaps your JavaScript defines a "Drupal behavior", in which case you depend on the supporting infrastructure for that (core/drupal). Ex:

example_library:
  js: path/to/some/file.js: {}
  dependencies:
    - core/drupal
    - core/jquery

Use #attached in your block's render array to attach the asset library:


// Assuming the variable containing your render array is called $build.
$build['#attached']['library'][] = 'mymodule/example_library';


Extensive documentation can be found at https://www.drupal.org/docs/8/creating-custom-modules/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-module.