add an additional item to an array in Drupal Settings javascript from php I've got a hook_node_view which I'm trying to add a property of the node to an array that I have created in the Drupal.settings 

drupal_add_js(array('embedded_videos'=&gt;array()));


So in the node_view I can do

function mymod_node_view($node, $view_mode, $langcode) {
if($node-&gt;type == 'video'){
   drupal_add_js(array(
    'vimn_video' =&gt; array('embedded_videos' =&gt; $node-&gt;nid,
      ),
    ),
  'setting');
}  


But this overwrites what is in there, whereas I want to add to the array. Because this node_view is running multiple times as I have 2 video nodes embedded into an article node. 

Any ideas appreciated. I am new to the usage of Drupal.settings javascript api.

edit: The issue was that I needed to put $node->nid into an array array($node->nid), then it will add an item to the array rather than overwriting it.
Your first declaration should indicate that you are passing a setting to drupal_add_js():

drupal_add_js(array('your_module' =&gt; array()), 'setting');


Then you can add other properties to your array in hook_node_view():

function your_module_node_view($node, $view_mode, $langcode) {
    $your_array = array(
      'vimn_video' =&gt; array(
        'embedded_videos' =&gt; array($node-&gt;nid), // NOTE: $node-&gt;nid as an array
      ),
    );
    drupal_add_js(array('your_module' =&gt; $your_array), 'setting');  
}  


You can retrieve the properties from javascript as:

Drupal.settings.your_module.vimn_video.embedded_videos; // an array with node ids.