Object.hasPath()

Find if the given path exists in the given Object.

Signature

Object.hasPath(target: Any, path: Array<String>): Boolean

Description

Find if the given path exists in the given Object.

Parameters

Parameter Type Required Description

target

Function

Yes

Target Object.

path

Function

Yes

Array of keys representing a path in target.

Return value

Type Description

Array

Indicates if the given path exists:
true = path exists
false = path doesn’t exist.

Examples

Object.hasPath({ a : { b : 'x' } }, ['a', 'b'])
true

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!