LearnFrenzy
Sign in Take a free test

Callbacks · Exercise 1 of 4

Callbacks Callbacks MCQ

  • 15 questions
  • Page 2 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Fifteen multiple-choice questions on JavaScript callbacks: synchronous and asynchronous callbacks, setTimeout, error-first callbacks, callback hell, inversion of control, this, consistent timing, async errors, parallel tasks and promisify. Pick an option to check your answer instantly.

Question 11 Hard

A function calls its callback immediately when data is cached and later (after a fetch) otherwise. What is the problem?

A Cached data cannot be passed to callbacks
B It causes a SyntaxError
C There is no problem
D Callers cannot rely on the order of their code – make it always asynchronous
Question page & discussion
Question 12 Hard

Why does try { setTimeout(() => { throw new Error("x"); }, 0); } catch (e) { … } not catch the error?

A The callback runs after the try block has finished, so the error is thrown outside it
B Errors thrown in arrow functions cannot be caught
C setTimeout catches errors itself
D catch needs a finally block
Question page & discussion
Question 13 Medium

What does a promisify helper do?

A Turns an error-first callback function into a function that returns a promise
B Makes a synchronous function run in parallel
C Converts a promise into a callback
D Removes errors from callbacks
Question page & discussion
Question 14 Medium

Three downloads are started together with callbacks. In which order do their callbacks run?

A Always in the order they were started
B In alphabetical order of file names
C In the order the downloads finish – store results by index to keep the request order
D All at the same moment
Question page & discussion
Question 15 Medium

Which is an advantage of promises over plain callbacks?

A Promises run synchronously
B A promise settles only once, and chains flatly with a single catch for errors
C Promises do not need the event loop
D Promises cannot fail
Question page & discussion
Up next · Exercise 2Predict the Output20 questions

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links