1var baseProperty = require('../internal/baseProperty'), 2 basePropertyDeep = require('../internal/basePropertyDeep'), 3 isKey = require('../internal/isKey'); 4 5/** 6 * Creates a function that returns the property value at `path` on a 7 * given object. 8 * 9 * @static 10 * @memberOf _ 11 * @category Utility 12 * @param {Array|string} path The path of the property to get. 13 * @returns {Function} Returns the new function. 14 * @example 15 * 16 * var objects = [ 17 * { 'a': { 'b': { 'c': 2 } } }, 18 * { 'a': { 'b': { 'c': 1 } } } 19 * ]; 20 * 21 * _.map(objects, _.property('a.b.c')); 22 * // => [2, 1] 23 * 24 * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c'); 25 * // => [1, 2] 26 */ 27function property(path) { 28 return isKey(path) ? baseProperty(path) : basePropertyDeep(path); 29} 30 31module.exports = property; 32 33