Lodash - prototype.at 方法
語法
_.prototype.at([paths])
此方法是 _.at 的包裝版本。
引數
[路徑] (...(string|string[])) − 要選取的屬性路徑。
輸出
(物件) − 返回新的 lodash 包裝例項。
示例
var _ = require('lodash');
var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
var result = _(object).at(['a[0].b.c', 'a[1]']).value();
console.log(result);
將上述程式儲存為 tester.js。執行以下命令以執行此程式。
命令
\>node tester.js
輸出
[ 3, 4 ]
lodash_seq.htm
廣告