当前位置:网站首页>[node] common methods of path module
[node] common methods of path module
2022-06-12 00:13:00 【FunctionKang】
path The module provides a series of methods to operate on the path ,path The return result of all methods of the module is a path string
- join
String concatenation , Generate new path
join The input parameters of the method are several strings ,join Method will use all stringsconst path = require("path"); const p = path.join("user", "file", "01.js"); // user\file\01.js\The backslashes are spliced together to create a new path - node Constant ( Commonly used for path operations )
- __dirname
The absolute path of the folder where the current file is located - __filename
Absolute path to the current file
- __dirname
- resolve
Convert parameters to absolute paths , Splice based on the absolute path of the folder where the current file is located
The above two cases will be spliced backward based on the absolute path of the folder where the current file is located , Generate new pathpath.resolve("file"); path.resolve("./file"); // example :F:\aaa\...\bbb\file
Withpath.resolve("/file"); // example :F:\file/The slash will start with the drive letter of the current file
There are many. , But it's not just arguments that start with slashes , Starting from the drive letter, the last parameter starting with a slash to all the last parameters are spliced in turnpath.resolve("a", "c", "b", "d", "e"); // F:\d\e path.resolve("/a", "/c", "b", "/d", "e"); // F:\file\...\a\c\b\d\e - parse
Parsing path , Parse the path string into a routing objectpath.parse("F:/aaa/bbb/ccc/path.js"); /* { root: 'F:/', dir: 'F:/aaa/bbb/ccc', base: 'path.js', ext: '.js', name: 'path' } */attribute describe root Drive letter of directory dir Absolute path base The full name of the file to which the path points ( Include file suffixes ) ext file type , If it's a folder , Is an empty string name File name
边栏推荐
- Experiment 6 constructor + copy construction
- What does the Red Cross of win10 folder status indicate
- (greedy + longest ascending subsequence) acwing 896 Longest ascending subsequence II
- 预解析与作用域
- JS -- prevent automatic recovery of page position
- C language Niuke net string space substitution
- Construction environnementale 2
- Pleasant and burden free cross process communication
- (digital statistics dp+good) acwing 338 Counting problem
- On the knowledge points of cookie attributes and the differences between webstorage and cookies?
猜你喜欢
![[industry application] an article on power digital transformation](/img/4a/d2d2795992cac8fb76135a117c3091.jpg)
[industry application] an article on power digital transformation

多路查找树

Do you want to take the postgraduate entrance examination? Will you be able to find a good job after graduate school?

(dp+ longest common subsequence) acwing 897 Longest common subsequence

Class. Getresource() and class Getresourceasstream() method

环境搭建2

DPT-FSNET: DUAL-PATH TRANSFORMER BASED FULL-BAND AND SUB-BAND FUSION NETWORK FOR SPEECH ENHANCEMENT

统一认证中心 Oauth2 高可用坑

【juc学习之路第5天】引用原子类和属性修改器

Experiment 7 class construction and static member function
随机推荐
WALLYS Qualcomm-Atheros-QCA9882-2T2R-MIMO-802.11ac-Mini-PCIe-WiFi 6E-Module-5G-high-power
Optimization method of win7 FPS
Read 5g RF terminal industry
(digital statistics dp+good) acwing 338 Counting problem
[day 5 of JUC learning] reference atomic classes and attribute modifiers
Pycharm file name taboo
苹果手机wps如何改字体大小
多路查找树
Share an open source, free and powerful video player library
SF14 | supertrend "super trend" indicator magic change and upgrade (source code)
926. Flip String to Monotone Increasing
苹果手机wps文件如何发送到qq邮箱
win10系统pscs6如何卸载
(dp) acwing 899. Edit distance
Meet o & M (I) common questions for O & M interview
環境搭建2
Acwing's first question solution attracted the first fan!!! Happy~~~
Redis的主从复制、哨兵模式和集群
[tense] 1. General present tense 2. Do not translate Chinese
R language spline curve piecewise linear regression model piecewise regression estimation of individual stock beta value analysis of yield data