path.sep


返回平台特定的路径片段分隔符:

  • Windows 上是 \
  • POSIX 上是 /

例如,在 POSIX 上:

'foo/bar/baz'.split(path.sep);
// 返回: ['foo', 'bar', 'baz']

在 Windows 上:

'foo\\bar\\baz'.split(path.sep);
// 返回: ['foo', 'bar', 'baz']

在 Windows 上,斜杠字符(/)和反斜杠字符(\)都可作为路径分隔符。 path 的方法只使用反斜杠(\)。

Provides the platform-specific path segment separator:

  • \ on Windows
  • / on POSIX

For example, on POSIX:

'foo/bar/baz'.split(path.sep);
// Returns: ['foo', 'bar', 'baz']

On Windows:

'foo\\bar\\baz'.split(path.sep);
// Returns: ['foo', 'bar', 'baz']

On Windows, both the forward slash (/) and backward slash (\) are accepted as path segment separators; however, the path methods only add backward slashes (\).