- 18 Oct 2024
-
DarkLight
-
PDF
objectHasOwnProperty
- Updated on 18 Oct 2024
-
DarkLight
-
PDF
objectHasOwnProperty Task Purpose
The objectHasOwnProperty task is used to check whether the object has a specified property as its own property. This is useful for checking if the object has inherited the property rather than being its own.
The result returns a boolean value (True or False) indicating whether the object has the given property as its own property. If the object has a property with the name contained in the string argument, it returns true. Otherwise it returns false.
Potential Use Case
This task is a convenient method to check if a specific property exists in an object (or not) since it returns true/false accordingly. Using this task also allows you to test for properties you have manually created on your current object.
Another benefit of objecthasOwnProperty
is that it can be initialized with any object by just using the string as an argument. It returns true if the value is available to the object, or it returns false. Lastly, if you just want to check for the existence of properties, and not necessarily what their value might be, then you could use this task.
Properties
Input and output properties are shown below.
Input | Type | Description |
---|---|---|
obj |
Object | Required. The object to test. |
prop |
String | Required. The string that contains the property to check. |
Output | Type | Description |
---|---|---|
result |
Boolean | The result is true if the object owns the specified property; false otherwise. |
Example 1
In this IAP example, the incoming Reference variable for prop
is "name" and the outgoing result
returns "True", indicating the object contains the specified property.
Example 2
In this IAP example, the incoming Reference variable for prop
is "type" and the result
returns "False", indicating the object does not contain that given property.