Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Wait -- an ES6 promise example
const wait = time => new Promise((resolve) => setTimeout(resolve, time));
wait(3000).then(() => console.log('Hello!')); // 'Hello!'

This comment has been minimized.

Copy link

@lubegasimon lubegasimon commented May 25, 2018

Hi, could you please help explain "const wait '= time =>' new Promise" especially the statements enclosed in single quote and how they related to the whole line of code ..



This comment has been minimized.

Copy link

@vixeven vixeven commented Aug 11, 2018

const wait = function(time) {
    return new Promise(function(resolve) {
	setTimeout(resolve, time)

.then(function() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment