Sometimes, we want to determine the OS path separator in JavaScript.
In this article, we’ll look at how to determine the OS path separator in JavaScript.
How to determine the OS path separator in JavaScript?
To determine the OS path separator in JavaScript, we can use the path module.
For instance, we write
const path = require("path");
console.log(path.sep);
to use the path.sep property to return the path separator string for the OS that the Node app is running on.
Conclusion
To determine the OS path separator in JavaScript, we can use the path module.