Error while altering js file Undefined index: scope in drupal_get_js() (line 4309
Just got into this function too to alter "folder/js_file.js" and the issue causing the 


  Notice: Undefined index: scope in drupal_get_js() (line 4309 of
  [DRUPAL_DIR]\includes\common.inc).


error is that there are times when the hook is called but "folder/js_file.js" is not yet in the array w/c just adds

[folder/js_file.js] =&gt; Array(
  [data] =&gt; [your_custom_js],
)


to the array but the scope, type, and other attributes are not there. So we first need to check if the array key exists like so:

if (isset($javascript['folder/js_file.js'])) {
  $file = drupal_get_path('module', 'mymodule') . '/your_custom_js.js';
  $javascript['folder/js_file.js']['data'] = $file;
}


That solves it. :)