Skip to content

Instantly share code, notes, and snippets.

@samarpanda
Last active January 20, 2019 06:53
Show Gist options
  • Select an option

  • Save samarpanda/0377fa759744dd9be22b3235d65ec900 to your computer and use it in GitHub Desktop.

Select an option

Save samarpanda/0377fa759744dd9be22b3235d65ec900 to your computer and use it in GitHub Desktop.

Quiz 14-01-2019

Question 1

button.addEventListener('click', () => {
  Promise.resolve().then(() => console.log('Microtask 1'))
  console.log('Listener 1')
});

button.addEventListener('click', () => {
  Promise.resolve().then(() => console.log('Microtask 2'))
  console.log('Listener 2')
});

//Output?

Question 2

button.addEventListener('click', () => {
  Promise.resolve().then(() => console.log('Microtask 1'))
  console.log('Listener 1')
});

button.addEventListener('click', () => {
  Promise.resolve().then(() => console.log('Microtask 2'))
  console.log('Listener 2')
});

button.click();
//Output?

Question 3

const nextClick = new Promise(resolve => {
  link.addEventListener('click', resolve, {once: true})
})

nextClick.then(event => {
  event.preventDefault();
})

link.click();
@samarpanda

Copy link
Copy Markdown
Author

@samarpanda

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment