What is the different between path.join(__dirname, "src/js") versus just __dirname + "src/js") in node.js?
            Asked
            
        
        
            Active
            
        
            Viewed 481 times
        
    1
            
            
         
    
    
        Maria Jane
        
- 2,353
- 6
- 23
- 39
1 Answers
0
            
            
        path.join takes cares of the / or lack of / on your strings. The second way you're doing it with pure javascript, which is ok.
path.join('/foo', 'bar')
will return /foo/bar, but
'/foo' + 'bar'
will return /foobar which might be not where you want to access
 
    
    
        Aschab
        
- 1,378
- 2
- 14
- 31
- 
                    is that all? why people type more than putting an extra '/'? – Maria Jane Oct 02 '16 at 03:22
- 
                    Readability more than anything. – Aschab Oct 02 '16 at 03:48