Sometimes, we want to go back 1 folder level with __dirname with JavaScript.
In this article, we’ll look at how to go back 1 folder level with __dirname with JavaScript.
How to go back 1 folder level with __dirname with JavaScript?
To go back 1 folder level with __dirname with JavaScript, we can use the '../
string.
For instance, we write
const path = require("path");
const p = path.join(__dirname, "../");
to call path.join
with __dirname
and "../"
to return a string with the path one level up from __dirname
.
Conclusion
To go back 1 folder level with __dirname with JavaScript, we can use the '../
string.