How do I pass the value of a PHP variable? I have the following code in Drupal 6.

drupal_add_js(array(
  'take_control_fb' =&gt; array(
      //          'pubKey' =&gt; variable_get('take_control_public_key', ''),
      'dataUrl' =&gt; base_path() . 'admin/build/take_control/fb/getfiles',
      'appUrl' =&gt; take_control_app_url(),
      'appDir' =&gt; $appDir,
      'extPath' =&gt; $extpath,
      'zipMimes' =&gt; take_control_zip_mimes(),
      'dirSeparator' =&gt; DIRECTORY_SEPARATOR,
      'validationString' =&gt; $validationString,
      'validationToken' =&gt; drupal_get_token($validationString),
      'curUserId' =&gt; fileowner(file_directory_path()))), 'setting');


I need to convert this, since drupal_add_js() is removed from Drupal 8. I can't use this to pass PHP variables to modulename.js file. How can I pass the PHP variable to JavaScript code?
In Drupal 8 drupal_add_css(), drupal_add_js() and drupal_add_library() have been removed, and we are supposed to use #attached.

$page['#attached']['library'][] = 'fluffiness/cuddly-slider';
$page['#attached']['drupalSettings']['fluffiness']['cuddlySlider']['foo'] = 'bar';


More details about how JavaScript can be added in Drupal 8 can be found in https://www.drupal.org/theme-guide/8/assets#configurable-javascript.