nodejs get file extension code example
Example 1: how to check file extension in node js
var path = require('path');
var ext = path.extname('/Users/Refsnes/demo_path.js');
console.log(ext);
Example 2: how to read file extension in a folder in node js
fs.readdir('./', (err, files) => {
files.forEach(file => {
// console.log(file);
// read extension
const extension = file.split(".").pop();
});
})