They do seem to have some strange restrictions on this. E.g. When you evaluate it the function returns undefined but it also outputs the array underneath. You can right click and save it to variable.
I think the point of this so that you cannot assign the output programmatically, there has to be a person who saves it to a variable by right clicking.
I can’t see any reason for preventing assigning the output programmatically.
The reason is absolutely security concerns. You don't want to leak a function that can expose a list of all objects on the JS heap.
queryObjects(Object.prototype) === queryObjects(Object)
in the console will output 'true', followed by two Arrays of different sizes.
Also, Google's doc [1] says:
> queryObjects(HTMLElement). Returns all HTML elements.
But it returns not just instances of HTMLElement (objects that derive from HTMLElement.prototype via the prototype chain) but subclasses as well (objects that derive from HTMLElement itself via the prototype chain, like HTMLBodyElement and HTMLHeadElement, which are not its instances)
[1] https://developer.chrome.com/docs/devtools/console/utilities...