From ecaee16d2318fec43a715f898929fbb7980d3e22 Mon Sep 17 00:00:00 2001 From: Xotic750 Date: Mon, 2 Nov 2015 12:23:59 +0100 Subject: [PATCH] Improve documentation of `toLength` by including examples. [ci skip] --- lodash.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lodash.js b/lodash.js index aa78a7936..0f4906978 100644 --- a/lodash.js +++ b/lodash.js @@ -9892,6 +9892,25 @@ * @category Lang * @param {*} value The value to convert. * @return {number} Returns the converted integer. + * @example + * + * _.toLength(NaN); + * // => 0 + * + * _.toLength(Infinity); + * // => 4294967295 + * + * var answer = { + * valueOf: function () { + * return 1; + * }, + * toString: function () { + * return 'one'; + * } + * }; + * + * _.toLength(answer); + * // => 1 */ function toLength(value) { return clamp(toInteger(value), 0, MAX_ARRAY_LENGTH);