Created
February 21, 2017 18:58
-
-
Save Kcko/29aaa9c02d9b0cca1cf7699a7e4ebd2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function timeout(milliseconds) { | |
// Create a new Deferred object | |
var deferred = $.Deferred(); | |
// Resolve the Deferred after the amount of time specified by milliseconds | |
setTimeout(deferred.resolve, milliseconds); | |
// Return the Deferred's Promise object | |
return deferred.promise(); | |
} | |
timeout(1000).then(function() { | |
console.log('I waited for 1 second!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment