Access selection from Automation Console

I’m starting to get familiar with Automation, and would like to study the attributes of selected objects from the console. In other words I’d like to be able to get the properties of a task using something like:

s=Selection
t=s.tasks[0]
t

→ [object Task: Miscellaneous] {active: true, added: Sat Aug 02 2008 .....

Is there an easy way to do that, or does it need to happen in the context of a script?

One option would be experimenting with Selection Object that belongs to Window class.

From API documentation:

Document Selection
A document’s Selection object belongs to the Window class, which in turn, belongs to the parent implied document.

An array of selected task objects:

document.windows[0].selection.tasks

An array of task names (string):

document.windows[0].selection.tasks.map(x => x.name)

Yep, that works. You can get the first task in the list with

document.windows[0].selection.tasks[0]

Thanks!