Lodash - toPath 方法
语法
_.toPath(value)
将值转换为属性路径数组。
参数
value (*) − 要转换的值。
输出
(Array) − 返回新的属性路径数组。
示例
var _ = require('lodash'); console.log(_.toPath('a.b.c')); console.log(_.toPath('a[0].b.c'));
将上述程序保存在tester.js中。运行以下命令执行该程序。
命令
\>node tester.js
输出
[ 'a', 'b', 'c' ] [ 'a', '0', 'b', 'c' ]