This article describes how to use the path. basename method in node. js. This article describes the method description, syntax, use examples, and source code implementation of path. basename. For more information, see
Method description:
Extract the last part of the path separated. (8. For details, see the example)
Syntax:
The Code is as follows:
Path. basename (p, [ext])
Because this method belongs to the path module, You need to introduce the path module (var path = require ("path") before use "))
Receiving parameters:
Path to be processed by p
Ext characters to be filtered
Example:
The Code is as follows:
Var path = require ("path ");
Path. basename ('/foo/bar/baz/asdf/quux.html ')
// Returns
'Quux.html'
Path. basename ('/foo/bar/baz/asdf/quux.html', '.html ')
// Returns
'Quux'
Var a = path. basename ('/foo/bar/baz/asdf/', '.html ');
// Returns
'Asdf'