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

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.