以下のこのコードが間違って実行されている理由を知りたいと思っています。Uncheck という関数を起動するチェックボックスがあります。ただし、クリックごとに0.4秒以下のようにすばやくクリックすると、失敗します。配列の値が重複しています。
HTML
<input type="checkbox" id="uni2198" name="uni" value="2198" onclick="Uncheck('2198')">
JS
unidadesSelecionadas = {};
function Uncheck(id) {
var idSelect = '#uni' + id;
if ($(idSelect).is(':checked')) {
if ($.inArray(parseInt(id), unidadesSelecionadas) == -1) {
unidadesSelecionadas.push(id);
}
} else {
unidadesSelecionadas.splice($.inArray(parseInt(id), unidadesSelecionadas), 1);
}
}