From what I understand a option elements that popuate select elements in HTML are an array.
So basically what i want to do is return an array string that is separated by commas.
Tried to do selecbox.options.join(',');, but got an error that its not supported; anyone have an idea why?
It is not an array. It is an HTMLCollection. It is "array-like"
In 2022, a week before EOL of Internet Explorer 11, the simplest vanilla JavaScript solution is using spread and Array map
UPDATE: Array.from is actually preferable to the spread since it is more obvious what is going on
Older answer that is compatible with IE11
from http://api.jquery.com/jQuery.each/ which CAN iterate over either:
Each HTML Option element has a value and a text and some more attributes.
A simple for loop can be used
the Array.apply posted by typeracer will return an array of HTMLOptionElements which still needs to be looped over or mapped to get at the values and texts
Here are a few versions that will return the same.
This fiddle will run in IE11 too