node.js中的path.extname方法使用说明

时间:2014-12-09    点击:106   

方法说明:

返回path路径文件扩展名,如果path以 ‘.' 为结尾,将返回 ‘.',如果无扩展名 又 不以'.'结尾,将返回空值。

语法:

复制代码 代码如下:

path.extname(p)

由于该方法属于path模块,使用前需要引入path模块(var path= require(“path”) )

接收参数:

p       path路径

例子:

复制代码 代码如下:

path.extname('index.html')
// returns
'.html'
path.extname('index.')
// returns
'.'
path.extname('index')
// returns
''

源码:

复制代码 代码如下:

exports.extname = function(path) {
  return splitPath(path)[3];
};

node.js中的console.time方法使用说明
node.js中的console.timeEnd方法使用说明
node.js中的path.basename方法使用说明
node.js中的path.delimiter方法使用说明
node.js中的path.dirname方法使用说明
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved