function debounce(fn, wait) { let timeout; return (...args) => { clearTimeout(timeout); timeout = setTimeout(() => fn(...args), wait); } } function autocomplete(datalist,communes) { // À compléter datalist.innerHTML = ''; for(let c of communes) { let option = document.createElement("option"); option.value = c; datalist.appendChild(option); } }