Seemed odd I couldn\'t find this one already asked, but here it goes!
I have an html as follows:
If you wanna go the modern way, you can do this:
const selectedOpts = [...field.options].filter((x) => x.selected);
The ... operator maps iterable (HTMLOptionsCollection) to the array.
If you're just interested in the values, you can add a map() call:
const selectedValues = [...field.options]
.filter((x) => x.selected)
.map((x)=>x.value);