Function isNumber

  • EN: Check whether it is a right number.

    ZH: 判断是否有效数字

    Usage:

    const ret1 = isNumber(123);
    const ret2 = isNumber('123');
    // Default: NaN, Infinity is not Number
    const ret3 = isNumber(Infinity);
    const ret4 = isNumber(Infinity, { isInfinityAsNumber: true });
    const ret5 = isNumber(NaN);
    const ret6 = isNumber(NaN, { isNaNAsNumber: true, isInfinityAsNumber: true });
    console.log(ret1, ret2, ret3, ret4, ret5, ret6);

    Output:

    true false false true false true
    

    Parameters

    • num: unknown

      被判断的值

    • options: IsNumberOptions = {}

    Returns boolean

    true 是数字