From b69ba06db9e0ad0750e5eb4aedeaf6f5856138b8 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 4 Dec 2015 08:35:45 -0800 Subject: [PATCH] Add a doc on path creation for `_.set`. [ci skip] --- lodash.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lodash.js b/lodash.js index 364524ea0..fdf45e840 100644 --- a/lodash.js +++ b/lodash.js @@ -11336,8 +11336,10 @@ } /** - * Sets the value at `path` of `object`. If a portion of `path` doesn't - * exist it's created. + * Sets the value at `path` of `object`. If a portion of `path` doesn't exist + * it's created. Arrays are created for missing index properties while objects + * are created for all other missing properties. Use `_.setWith` to customize + * `path` creation. * * @static * @memberOf _ @@ -11378,13 +11380,7 @@ * @returns {Object} Returns `object`. * @example * - * function customizer(nsValue) { - * if (!_.isObject(nsValue)) { - * return {}; - * } - * } - * - * _.setWith({ '0': { 'length': 2 } }, '[0][1][2]', 3, customizer); + * _.setWith({ '0': { 'length': 2 } }, '[0][1][2]', 3, Object); * // => { '0': { '1': { '2': 3 }, 'length': 2 } } */ function setWith(object, path, value, customizer) {