Attach js to the module using libraries with inline property
drupal_add_js() has been deprecated, and you cannot use it anymore.

Pass the inline variables with the #attached property as :

$var[$delta]['#attached']['drupalSettings']['yourmodule']['example'] = $example;


And then access the example variable in the JS file as

drupalSettings.yourmodule.example


Note: I have not tried this code, but I think it should work.