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 ValueDescription
BooleanReturns 'true' if the specified path is a direct property of the given object; otherwise, 'false'.

Sample

ExampleResultDescription
has({ name: 'John', age: 30 }, 'name')trueReturns 'true' because 'name' is a direct property of the object.
has({ name: 'John', age: 30 }, 'city')falseReturns 'false' because 'city' is not a direct property of the object.

To view all Object functions, click here.