Home > Web Front-end > JS Tutorial > body text

Instructions for using the path.extname method in node.js_node.js

WBOY
Release: 2016-05-16 16:28:12
Original
1833 people have browsed it

Method description:

Returns the path file extension. If the path ends with '.', '.' will be returned. If there is no extension and does not end with '.', a null value will be returned.

Grammar:

Copy code The code is as follows:

path.extname(p)

Since this method belongs to the path module, the path module needs to be introduced before use (var path= require(“path”) )

Receive parameters:

p path

Example:

Copy code The code is as follows:

path.extname('index.html')
// returns
'.html'
path.extname('index.')
// returns
'.'
path.extname('index')
// returns
''

Source code:

Copy code The code is as follows:

exports.extname = function(path) {
Return splitPath(path)[3];
};
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template