title: Nodejs difference between two paths
body: <p>I am trying to get the difference between two path. I've come with a solution, but I am not really happy about it, even if it works. Is there a better / easier way to do this?</p>
  
  <pre><code>var firstPath =  '/my/first/path'
    , secondPath = '/my/first/path/but/longer'
  
  // what I want to get is: '/but/longer'
  
  // my code:
  var firstPathDeconstruct = firstPath.split(path.sep)
    , secondPathDeconstruct = secondPath.split(path.sep)
    , diff = []
  
  secondPathDeconstruct.forEach(function(chunk) {
    if (firstPathDeconstruct.indexOf(chunk) &lt; 0) {
      diff.push(chunk)
    }
  })
  
  console.log(diff)
  // output ['but', 'longer']
  </code></pre>