Rest operator work with DOM. JS Code example open

Rest operator work with DOM. JS Code example

    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)
    }
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation