Skip to content

Instantly share code, notes, and snippets.

@mtliendo
Created April 29, 2019 18:09
Show Gist options
  • Save mtliendo/9a6c127cfc6b239ddf551febfa8dfc58 to your computer and use it in GitHub Desktop.
Save mtliendo/9a6c127cfc6b239ddf551febfa8dfc58 to your computer and use it in GitHub Desktop.
An quick intro to understanding callback functions via forms
// First let's grab a form
console.log('first')
const someForm = document.getElementById('some-form')
// Next, we'll add an event listener with the event and a callback function
// Note that the anonymous function is
someForm.addEventListener('submit', (evt) => {
console.log('second')
//this is an asynchronous function.
})
console.log('third')
// Note that the log statements will be "first", "third", "second"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment