var path = require('path');
//Return the extension:
var ext = path.extname('/Users/Refsnes/demo_path.js');
console.log(ext);

              

.js