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

    Function isTypeof

    • Checks if a value is of a given type.

      检查值是否为给定类型。

      Type Parameters

      • T

      Parameters

      • s: unknown

        The value to check. 要检查的值

      • type: string

        The type to check against. 要检查的类型

      Returns s is T

      True if the value is of the given type, false otherwise. 如果值为给定类型则返回 true,否则返回 false

      isTypeof(null, 'null') // => true
      isTypeof(undefined, 'undefined') // => true
      isTypeof({}, 'object') // => true
      isTypeof([], 'array') // => true
      isTypeof(new Map(), 'map') // => true
      isTypeof(() => {}, 'function') // => true
      isTypeof(42, 'string') // => false