M
path.extname
History
Added in: v0.1.25
v0.1.25
Introduced in: v0.10.0
v0.10.0
Passing a non-string as the
path argument will throw now.v6.0.0
path.extname(path): string
Attributes
The path.extname() method returns the extension of the path, from the last
occurrence of the . (period) character to end of string in the last portion of
the path. If there is no . in the last portion of the path, or if
there are no . characters other than the first character of
the basename of path (see path.basename()) , an empty string is returned.
path.extname('index.html'); // Returns: '.html' path.extname('index.coffee.md'); // Returns: '.md' path.extname('index.'); // Returns: '.' path.extname('index'); // Returns: '' path.extname('.index'); // Returns: '' path.extname('.index.md'); // Returns: '.md'
A TypeError is thrown if path is not a string.