node js get extension from filename 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 get the extension from filename using javascript
var ext = fileName.substr(fileName.lastIndexOf('.') + 1);
Example 3: node js get file name without extension
filename.split('.').slice(0, -1).join('.')