_.property(path)
Creates a function that returns the value at path
of a given object.
Since
2.4.0
Arguments
path
(Array|string): The path of the property to get.
Returns
(Function): Returns the new accessor function.
Example
var objects = [{ 'a': { 'b': 2 } },{ 'a': { 'b': 1 } }];_.map(objects, _.property('a.b'));// => [2, 1]_.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');// => [1, 2]
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .