Function intToBool

  • Return val unless val is a number in which case we convert to boolean. This is useful when a boolean value is stored as a 0/1 (e.g. in JSON) and we still want to maintain string values. null and undefined are returned as is. E.g. checkbox may be boolean or 'radio'.

    Parameters

    • val: undefined | string | number | boolean

    Returns boolean | string | undefined