mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 11:57:49 +00:00
Improve toNumber documentation by including examples. [ci skip]
This commit is contained in:
committed by
John-David Dalton
parent
ecaee16d23
commit
67701944f1
22
lodash.js
22
lodash.js
@@ -9924,6 +9924,28 @@
|
|||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to process.
|
* @param {*} value The value to process.
|
||||||
* @returns {number} Returns the number.
|
* @returns {number} Returns the number.
|
||||||
|
* @examples
|
||||||
|
*
|
||||||
|
* _.toNumber(undefined);
|
||||||
|
* // => NaN
|
||||||
|
*
|
||||||
|
* _.toNumber(null);
|
||||||
|
* // => 0
|
||||||
|
*
|
||||||
|
* _.toNumber('-0');
|
||||||
|
* // => -0
|
||||||
|
*
|
||||||
|
* var answer = {
|
||||||
|
* valueOf: function() {
|
||||||
|
* return 1;
|
||||||
|
* },
|
||||||
|
* toString: function () {
|
||||||
|
* return 'one';
|
||||||
|
* }
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* _.toNumber(answer);
|
||||||
|
* // => 1
|
||||||
*/
|
*/
|
||||||
function toNumber(value) {
|
function toNumber(value) {
|
||||||
if (isObject(value)) {
|
if (isObject(value)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user