Tutorials References Exercises Videos Menu
Create Website Get Certified Upgrade

Node.js path.extname() Method

❮ Path Module


Example

Get the extension from a file path:

var path = require('path');

var ext = path.extname('/Users/Refsnes/demo_path.js');
console.log(ext);
Run example »

Definition and Usage

The path.extname() method returns the extension of a file path.


Syntax

path.extname(path);

Parameter Values

Parameter Description
path Required. The file path to search in

Technical Details

Return Value: The extension, as a String
Node.js Version: 0.1.25

❮ Path Module