4.17.11
3.10.1
2.4.2
1.3.1

_.property(path)

Creates a function that returns the value at path of a given object.

Since

2.4.0

Arguments

argument
path
type
(Array|string)
description
The path of the property to get.

Returns

(array)

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]
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]