Next.js Discord

Discord Forum

Is there a easier way to check an deep object's inner properties?

Unanswered
Virginia's Warbler posted this in #help-forum
Open in Discord
Virginia's WarblerOP
This is more of a plain JS question. But lets say if I have deeply nested obejcts like xxx.yyy.zzz.aaa

I can do a series of checks to see: if xxx have yyy && if xxx.yyy have zzz && if xxx.yyy.zzz have aaa

But is there an easy way?

7 Replies

xxx?.yyy?.zzz?.aaa
@joulev xxx?.yyy?.zzz?.aaa
This would still give this warning
Virginia's WarblerOP
Thank you. Those 2 are helpful
@Anay-208 | Ping in replies Why do you want to check tho? I can recommend something based on that
Virginia's WarblerOP
Whatever you want to recommend, please recommend
I just want a syntacally easy way to check deeply nested objs
@Virginia's Warbler Whatever you want to recommend, please recommend
if its too nested, then you can use something like zod to safe parse it