From e25369a30672514c9902d95939489f6b6f0a8d9d Mon Sep 17 00:00:00 2001 From: Xotic750 Date: Mon, 2 Nov 2015 11:57:42 +0100 Subject: [PATCH] Improve documents for `_.toString` by including examples. [ci skip] --- lodash.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lodash.js b/lodash.js index 86c1b2e13..fa7780aaf 100644 --- a/lodash.js +++ b/lodash.js @@ -10019,12 +10019,34 @@ /** * Converts `value` to a string if it's not one. * An empty string is returned for `null` and `undefined` values. + * The number literals `-0` and `0` preserve their sign to become `'-0'` and `'0'`. + * This method is consistant with `value + ''` coersion rather than casting + * with `String(value)`. * * @static * @memberOf _ * @category Lang * @param {*} value The value to process. * @returns {string} Returns the string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * var answer = { + * valueOf: function() { + * return 1; + * }, + * toString: function () { + * return 'one'; + * } + * }; + * + * _.toString(answer); + * // => '1' */ function toString(value) { // Exit early for strings to avoid a performance hit in some environments.