How to print out the final selector in a jQuery method chain

If I have the following jQuery chain

 let mpath = $('.wlc2022.confirm').find('.something');

how can I print out ".something" or "something" (in either jQuery or raw JavaScript syntax) to the console window because its the last selector that mpath is looking for?

I have tried...

console.log(mpath.val)
console.log(mpath.value)

But nothing so far...


There is no API for that in modern (post-3.0) versions of jQuery. There used to be a .selector property on jQuery objects, but it was removed because it was unreliable.

Note also that mpath itself is not "looking for" anything; it gets the result of the jQuery-based expression. Probably the best way to do what you want would be to construct some sort of utility around that expression pattern, and have it retain that last selector and make it available somehow.