JSFiddle - React, Tailwind, and code Playground

HTML

<select multiple>
    <option value = 1>Uno</option>
    <option value = 2>Dos</option>
    <option value = 3>Tres</option>
</select>
<p></p>

JavaScript

var select = document.getElementsByTagName("select")[0],
    p = document.getElementsByTagName("p")[0],
    array = [];

select.addEventListener("click", function(e){
    var seleccionado = e.target.value,
        posicion = array.indexOf(seleccionado);
    
    if (posicion > -1)
        array.splice(posicion, 1);
    else
        array.push(seleccionado);
    
    p.innerHTML = "Array: " + array;
}, false);