title: recursion without explicitly setting variable javascript
body: <p>Here are two working versions (for Node.js) of the same recursive function.</p>
  
  <p><strong>Version 1</strong></p>
  
  <pre><code>function getDependencies(mod, result) {
    result = result || []
    var dependencies = mod.dependencies || []
    Object.keys(dependencies).forEach(function(dep) {
      var key = dep + '@' + mod.dependencies[dep].version
      if (result.indexOf(key) === -1) result.push(key)
      getDependencies(mod.dependencies[dep], result) // COMPARE THIS LINE
    })
    return result.sort()
  }
  </code></pre>
  
  <p><strong>Version 2</strong></p>
  
  <pre><code>function getDependencies(mod, result) {
    result = result || []
    var dependencies = mod.dependencies || []
    Object.keys(dependencies).forEach(function(dep) {
      var key = dep + '@' + mod.dependencies[dep].version
      if (result.indexOf(key) === -1) result.push(key)
      result = getDependencies(mod.dependencies[dep], result) // COMPARE THIS LINE
    })
    return result.sort()
  }
  </code></pre>
  
  <p>How does version 1 of the function work, as compared to version 2, without explicitly setting the result variable?</p>