@nevware21/ts-utils
    Preparing search index...

    Function objPropertyIsEnumerable

    • The objPropertyIsEnumerable() method returns a Boolean indicating whether the specified property is enumerable and is a property of the specified object. This method is similar to the native Object.prototype.propertyIsEnumerable() method, but it is a standalone function that can be used without needing to call it on the object itself. This will attempt to use the native method if it exists and is callable, otherwise it will use a helper implementation that will check for the property on the instance provided, if that instance has a propertyIsEnumerable method it will be called, otherwise it will check whether the property is available on the instance and if it is enumerable.

      Parameters

      • obj: any

        The object on which to check if the property is enumerable

      • prop: PropertyKey

        The property name or symbol to check

      Returns boolean

      A Boolean indicating whether the specified property is enumerable

      0.12.0

      const obj = {};
      const arr = [];
      obj.property1 = 42;

      // Custom property is enumerable
      console.log(objPropertyIsEnumerable(obj, "property1")); // true

      // Array length is not enumerable
      console.log(objPropertyIsEnumerable(arr, "length")); // false

      // Checking a property that doesn't exist returns false
      console.log(objPropertyIsEnumerable(obj, "nonExistent")); // false