Skip to content

Instantly share code, notes, and snippets.

@Shurlow
Created August 8, 2018 18:26
Show Gist options
  • Save Shurlow/6bc9c2d8e930fe5546053923818881fb to your computer and use it in GitHub Desktop.
Save Shurlow/6bc9c2d8e930fe5546053923818881fb to your computer and use it in GitHub Desktop.
Intervals & Timeouts Lesson Notes

Intervals & Timeouts

Objectives

  • Describe what it means for code to be asynchronous
  • Write code that is delayed a variable number of seconds

Guiding Questions

  • In what order will the following console.log statements be executed? Why?

    console.log('A')
    setTimeout(function () {
      console.log('B')
    }, 500)
    console.log('C')

    Your answer...

  • In what order will the following console.log statements be executed? Why?

    console.log('A')
    setTimeout(function () {
      console.log('B')
    }, 0)
    console.log('C')

    Your answer...

  • How can you set a function to run every X number of milliseconds? How can you stop it from running?

    Your answer...

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