@pengzhanbo/utils - v3.7.3
    Preparing search index...

    Function toNumber

    • Converts a value to a number

      将值转换为数字

      Parameters

      • v: unknown

        The value to convert. 要转换的值

      Returns number

      The converted number, or NaN if conversion is not possible. 转换后的数字,如果无法转换则返回 NaN

      Symbols are specially handled: Number(Symbol()) would throw a TypeError, so this function returns NaN for symbols instead.

      Symbol 被特殊处理:Number(Symbol()) 会抛出 TypeError,因此此函数对 Symbol 返回 NaN

      toNumber('42') // => 42
      toNumber('hello') // => NaN
      toNumber(undefined) // => NaN