const form = document.querySelector('form') form.addEventListener('submit', event => { event.preventDefault() const title = form.title.value const text = form.text.value const description = form.description.value saveForm(title, text, description) }) // Rest function saveForm(...args) { const [title, text, description] = args const formData = { date: new Date().toLocaleDateString(), title, text, description } console.log('Ford data:', formData) }
Rest operator work with DOM. JS Code example
More
lil-code© | 2022 - 2024
Go Top