has
Modified on Thu, 24 Aug 2023
Description
Use this function to check if the specified path is a direct property of the given object.
Syntax
has(object: T, path: PropertyPath)
Returns
Return Value | Description |
---|---|
Boolean | Returns 'true' if the specified path is a direct property of the given object; otherwise, 'false'. |
Sample
Example | Result | Description |
---|---|---|
has({ name: 'John', age: 30 }, 'name') | true | Returns 'true' because 'name' is a direct property of the object. |
has({ name: 'John', age: 30 }, 'city') | false | Returns 'false' because 'city' is not a direct property of the object. |
To view all Object functions, click here.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article