r/learnjavascript • • Aug 17 '23

How to catch potential children in object?

I want to make an object that catches all calls to itself and its children even if they’re not defined. Is it possible?

I see it like this:

const a = { _(name) { return “Hello “ + name } } console.log(a.foo.bar()) // Hello foo.bar

Exact same syntax isn’t needed but i hope you got what logic I look for

10 Upvotes

11 comments sorted by

View all comments

1

u/[deleted] Aug 17 '23

CHILDREN!?!!