1

What is the different between path.join(__dirname, "src/js") versus just __dirname + "src/js") in node.js?

Maria Jane
  • 2,353
  • 6
  • 23
  • 39

1 Answers1

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