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

    Function toTruthy

    • guard function that returns if val is truthy

      守卫函数,返回 val 是否为真值

      Type Parameters

      • T

        The type of elements in the array / 数组元素的类型

      Parameters

      • val: T

        The value to check. 要检查的值

      Returns val is NonNullable<T>

      True if the value is truthy, false otherwise. 如果值为真值则返回true,否则返回false

      [1, 2, 3, '', false, undefined].filter(toTruthy) // => [1, 2, 3]