path.join([...paths])
path.join() 方法使用平台特定的分隔符将所有给定的 path 片段连接在一起,然后对生成的路径进行规范化。
【The path.join() method joins all given path segments together using the
platform-specific separator as a delimiter, then normalizes the resulting path.】
零长度的 path 段会被忽略。如果连接后的路径字符串是零长度字符串,则会返回 '.',表示当前工作目录。
【Zero-length path segments are ignored. If the joined path string is a
zero-length string then '.' will be returned, representing the current
working directory.】
path.join('/foo', 'bar', 'baz/asdf', 'quux', '..');
// Returns: '/foo/bar/baz/asdf'
path.join('foo', {}, 'bar');
// Throws 'TypeError: Path must be a string. Received {}' 如果任何路径段不是字符串,则会抛出 TypeError。
【A TypeError is thrown if any of the path segments is not a string.】