Lodash -prototype.at 方法

语法

_.prototype.at([paths])

此方法是 _.at 的包装器版本。

参数

  • [paths] (...(string|string[])) − 要选择的属性路径。

输出

  • (Object) − 返回新的 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.html