title: global variable return in function
body: <p>I have using node module that reads firewall ip rules from ubuntu and using this function:</p>
  
  <pre><code>function lists(table, chain, cb) {
  var ip = [];
  // Accepts optional table argument
  if(!cb) {
      cb = chain;
      chain = table;
      table = undefined;
  }
  var rule = {
      list : true,
      chain : chain,
              table : table,
      action : '-L',
      sudo : true
  };
  
  lazy(iptables(rule).stdout)
      .lines
      .map(String)
      .skip(2)
      .map(function (line) {
          // packets, bytes, target, pro, opt, in, out, src, dst, opts
          var fields = line.trim().split(/\s+/, 9);
  
          ip.push(fields[7]);
          console.log(ip);
  
      })
      return ip;
  }
  </code></pre>
  
  <p>The problem is that console.log(ip) gets correct ip values and return ip gets undefined variable value...so how can i return array of ip in return(ip) so when i call this function from main program then i can compare if ip in array...i define global array variable at the beggining of function (var ip = [];) but return ip gets undefined variable....how can i return global ip array variable in return(ip)?</p>