当前位置:网站首页>Path Join() and path The difference between resolve()
Path Join() and path The difference between resolve()
2022-06-22 10:36:00 【Ah Fei】
nodejs in path.join() and path.resolve()
Basic introduction
__dirname: Returns the absolute path of the current file
introduce path modular
const path = require('path')
Use

path.join()
path.join() The main function is to splice paths
path.join Method is used to connect the path . The main purpose of this method is , Will correctly use the path separator of the current system ,Unix System is ”/“,Windows System is ”\“.
console.log(path.join('a', 'b', '..', 'c/', './d'));
// take path The pieces are connected
// Output :a/c/d
path.resolve()
path.resolve() Method is used to convert a relative path to an absolute path .
/ As the root of the absolute path , encounter / Then go back to root directory resolution
It can accept multiple parameters , Indicate the path to enter in turn , Until the last parameter is converted to an absolute path . If the absolute path cannot be obtained according to the parameters , Take the current path as the benchmark . Except for the root directory , The return value of this method has no trailing slash
path.resolve(); // The absolute path of the directory is returned by default , be equal to __dirname
path.resolve('/foo/bar', './baz')
// '/foo/bar/baz'
path.resolve('/foo/bar', '/tmp/file/')
// '/tmp/file'
The effect of execution is similar to cd operation
cd /foo/bar ==> /foo/bar
cd ./baz ==> /foo/bar
cd /tmp/file ==> /tmp/file
边栏推荐
- 传iPhone 14将全系涨价;TikTok美国用户数据转移到甲骨文,字节无法访问;SeaTunnel 2.1.2发布|极客头条...
- 每日一题day5-1636. 按照频率将数组升序排序
- 超简单的C语言贪吃蛇 不闪屏 双缓冲
- [backtrader source code analysis 51] simple interpretation of the source code of seven files in observers (boring, for reference only)
- Bluetooth, WiFi, ZigBee, Lora, Nb lot, call signal, network signal 4G
- 电装中国采用 Oracle HCM 云技术解决方案加速人力资源数字化转型
- 符合我公司GIS开源解决方案的探讨
- 学会用VisualStudio开发人员工具查看对象模型
- TCP建立连接过程(深入源码理解3次握手)
- Don't be silly enough to distinguish hash, chunkhash and contenthash
猜你喜欢

中坚力量!优炫软件入选2022年中国数字安全百强

2022各大厂最新总结的软件测试宝典,看完不怕拿不到offer
![[LineCTF2022]BB](/img/9d/c5b0ce1e603d40efc5245ba074aa77.png)
[LineCTF2022]BB

The future of Dao: an organization primitive for building Web3

Vs2022 connecting to SQLSERVER database tutorial

追更这个做嵌入式的大佬

Summary of neural network training trick
![[this tool, combined with JMeter, will increase your work efficiency by at least 80%, which is highly recommended]](/img/44/600d886a5dedd7a27ed923f6ffef53.png)
[this tool, combined with JMeter, will increase your work efficiency by at least 80%, which is highly recommended]

Catch up with this big guy

Software project management 8.3 Agile project quality activities
随机推荐
[机缘参悟-28]:鬼谷子-内揵篇-保全自己,说服上司
【直播回顾】战码先锋第六期:共建测试子系统,赋能开发者提高代码质量
On the routing tree of gin
信号完整性(SI)电源完整性(PI)学习笔记(二十四)差分对与差分阻抗(四)
Using computed columns in laravel
[LineCTF2022]BB
[untitled] repair log
Basic principles of the Internet
牛客网——华为题库(31~40)
Zuckerberg's latest VR prototype is coming. It is necessary to confuse virtual reality with reality
Kirin software and Geer software focus on the development of network data security
【Shell】常用指令集锦
2022各大厂最新总结的软件测试宝典,看完不怕拿不到offer
外贸专题:外贸邮件营销模板
How harmful is the code signature certificate once it is leaked
10-2xxe vulnerability principle and case experiment demonstration
Foreign trade topic: foreign trade e-mail marketing template
MySQL skip scan range small function to solve big problems?
Vs2022 connecting to SQLSERVER database tutorial
jg_使用easyexcel读取excel_20220619