Contents

JSObjectHasPropertyCallback

The callback type for determining whether an object has a property.

Declaration

typealias JSObjectHasPropertyCallback = (JSContextRef?, JSObjectRef?, JSStringRef?) -> Bool

Parameters

  • ctx:

    The execution context to use.

  • object:

    The Jsobjectref to search for the property.

  • propertyName:

    A Jsstringref that contains the name of the property to find.

Return Value

true if object has the property; otherwise, false.

Discussion

If you name your function HasProperty, you declare it like this:

bool HasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);

If this function returns false, the hasProperty request forwards to the object’s statically declared properties, then its parent class chain (which includes the default object class), and then its prototype chain.

This callback enables optimization in cases where you only need to know a property’s existence, not its value, and computing its value is expensive.

If this callback is NULL, the system uses the getProperty callback to service hasProperty requests.

See Also

Managing Callbacks