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

    Function isKeyof

    • Check if an object has a property.

      检查一个对象是否有属性。

      Type Parameters

      • T extends object

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

      Parameters

      • obj: T

        The object to check. 要检查的对象

      • key: PropertyKey

        The key to check for. 要检查的键

      Returns key is keyof T

      True if the object has the property, false otherwise. 如果对象具有该属性则返回 true,否则返回 false

      isKeyof({ a: 1, b: 2 }, 'a') // => true
      isKeyof({ a: 1, b: 2 }, 'c') // => false