![]() |
VOOZH | about |
The fs.Dirent.name property is an inbuilt application programming interface of class fs.Dirent within File System module which is used to provide the name of the particular dirent.
Syntax:
const dirent.name
Parameter: This property does not accept any parameter.
Return Value: This property returns the name of the particular dirent.
Below programs illustrates the use of fs.dirent.name property in Node.js:
Example 1: Filename: index.js
Run index.js file using the following command:
node index.js
Output:
abcd.cer cert.cer certfile.cer certificate1.cer example.txt features filename.txt
Example 2: Filename: index.js
Run index.js file using the following command:
node index.js
Output:
Dirent { name: 'books.txt', [Symbol(type)]: 1 }
abcd.cer
Dirent { name: 'certfile.cer', [Symbol(type)]: 1 }
cert.cer
Dirent { name: 'example.com_index.html', [Symbol(type)]: 1 }
certificate1.cer
Dirent { name: 'features', [Symbol(type)]: 2 }
example.txt
Reference: https://nodejs.org/dist/latest-v12.x/docs/api/fs.html#fs_dirent_name