Trying to Conditionally Add JS File to page if in a paragraph block reference on that page
In Drupal 8 drupal_add_js() as well as drupal_add_library() and drupal_add_css() were removed in favor of #attached. Means you now can use the #attached key in any render array or preprocess or build function to attach your library only where you need it. Please read the following articles on DO:

[Docs] Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 theme

[Docs] Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 module

[Forum] Adding js to the block through module Drupal 8