What are fs constants (fs.constants) and what is its use in the fs.access method, as shown here? - https://www.geeksforgeeks.org/node-js-fs-access-method/
What use do they have?
It's essentially an enum - an object whose properties describe (and whose values uniquely identify) a particular flag or indicator used with fs. See the docs.
Returns an object containing commonly used constants for file system operations.
You can use them in combination with fs operations to (reasonably) concisely and readably describe what you want to do.
For example, with the fs.access from your link:
mode: It is an integer value that denotes the permission to be tested for. The logical OR operator can be used to seperate multiple permission. It can have the values
fs.constants.F_OK, fs.constants.R_OK, fs.constants.W_OKandfs.constants.X_OK. It is an optional parameter. The default value isfs.constants.F_OK.
The actual values contained inside the object don't really matter (other than that they're all distinct from each other, and that they can be used with | for a bitmask).

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With