Lodash - toPath 方法
語法
_.toPath(value)
將值轉換為屬性路徑陣列。
引數
value (*) − 要轉換的值。
輸出
(陣列) − 返回新的屬性路徑陣列。
例子
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' ]
lodash_util.htm
廣告