Skip to content

Instantly share code, notes, and snippets.

@tikotus
Created August 11, 2017 13:41
Show Gist options
  • Save tikotus/d5a80a59f8db3b7eaaedbb7daa17d0ac to your computer and use it in GitHub Desktop.
Save tikotus/d5a80a59f8db3b7eaaedbb7daa17d0ac to your computer and use it in GitHub Desktop.
setTimeout(() => {
console.log("hello")
setTimeout(() => {
console.log("world")
}, 1000)
}, 1000)
const setTimeoutPromise = function(text) {
return new Promise((resolve) => {
setTimeout(() => {
console.log(text)
resolve()
}, 1000)
})
}
setTimeoutPromise("hello")
.then(() => setTimeoutPromise("world"))
.then(() => setTimeoutPromise("1"))
.then(() => setTimeoutPromise("2"))
.then(() => setTimeoutPromise("3"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment