title: Using global variables in nodered Javascript (HowTo)
body: <p>I'm trying to using a make a lock variable in Node-Red. for that I've wrote the following function! </p>
  
  <pre><code> global.set('lockvariable',0);
  
  
   var payload  = msg.payload; 
   if (msg.payload[0].value === 0  &amp;&amp; global.get('lockvariable')=== 0){
      msg.payload  =global.get('lockvariable');  
      global.set('lockvariable',1);
  
   } else if (global.get('lockvariable') === 1){
      msg.payload = global.get('lockvariable');
  
   }
   return msg;
  </code></pre>
  
  <p>The Problem that I have is that the return value is always 0. I guess because I'm writing the initialization the first line ! since I'm from the C world I don't get what I'm missing here! </p>
  
  <p>Thanks for any hint! </p>