baseToNumber
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
Overthinking ruins you. Ruins the situation, twists it around, makes you worry and just makes everything much worse than it actually is. — Unknown
本文为 《lodash 源码阅读》 系列文章,后续内容会在 github 中发布,欢迎 star,gitbook 同步更新。
import isSymbol from '../isSymbol.js';
/** 声明 NAN 变量 */
const NAN = 0 / 0;
/**
* `toNumber`的基本实现,它不能确保正确转换二进制,十六进制或八进制字符串值。
*
* @private
* @param {*} value 需要处理的值
* @returns
baseToNumber
相较于 Number()
,主要增加了对 Symbol
转换的优化,针对 Symbol
的特殊处理原因,我另起一篇文章讲解 从 ECMAScript 中理解 Symbol 类型转换。