path.basename code example
Example 1: path.basename nodejs
/* The path.basename() method returns the last portion of a path,
similar to the Unix basename command. Trailing directory separators
are ignored, see path.sep. */
path.basename('/foo/bar/baz/asdf/quux.html');
// Returns: 'quux.html'
path.basename('/foo/bar/baz/asdf/quux.html', '.html');
// Returns: 'quux'
Example 2: node.js name of file
var path = require('path');
var scriptName = path.basename(__filename);