How to get the file name from a path in Node.js?
Originally posted here!
To get the file name or the last portion from a path, you can use the basename() method from the path module in Node.js.
Let's say we have a pathname called /app/controllers/index.js like this,
// pathname
const pathname = "/...
melvingeorge-me.hashnode.dev2 min read