kwxjog
Last Updated: February 25, 2016
·
70
· richardgong1987
Psb  1

path.join() method

path.join()

path.join() that's easy to confuse method:

var path = require('path');
var pa = path.join('/foo', 'bar', 'baz/asdf', 'quux', '..');

console.log(pa);///foo/bar/baz/asdf

consider:

var path = require('path');
var pa = path.join('//foo//', '//bar/', '///baz/asdf', '//quux', '/..');

console.log(pa);///foo/bar/baz/asdf

It's the same

here,,we can respect path.join() methed as a combin method

var path = require('path');
var pa = path.normalize('//foo//'+ '//bar/'+'///baz/asdf'+ '//quux'+'/..');

console.log(pa);//=>foo/bar/baz/asdf
Say Thanks
Respond