get values of number boxes (and other objects)

I feel like I’m missing something obvious, but is it possible to retrieve a value of a max object in a patch with js? I don’t see any documentation or examples of this. I’m looking to do something like:
var obj = this.patcher.getnamed("mynumberobject");
var myvar = mynumberobject.value;

where "mynumberobject" is the scripting name of a number box.
Looking at the docs, it’s clear that "value" isn’t a Maxobj property, nor is there a "get" method. How would one do this?

Indeed there is. It’s probably not documented because there’s no JS
function for it per se, but you can build your own. Below is an
example of how to retrieve the names of all matrices in a patch. The
basic technique is to iterate through patcher objects and use the JS
functions connect()/disconnect() to invisibly talk to patcher objects
without a user ever seeing actual patch coords.

Wes, your solution is a nice workaround but as far as I can see it has two drawbacks: 1) when sending the message getname, the name is also ouput in the max patch. 2) this only works when the object who’s info you need is in the same patch

How about a method that, like [grab], retreives the results of a message? Something like this:

var name = myMaxObj.grab("getname", 2); // second argument is the outlet to retrieve