Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var timer = function(length, resolve) {
- setTimeout(function () {
- console.log('Timeout done.');
- resolve();
- }, length);
- }
- timer(4000, () => alert('All done!'));
- var timer = function(length) {
- return new Promise(function (resolve, reject) {
- setTimeout(function () {
- console.log('Timeout done.');
- resolve();
- }, length);
- });
- }
- timer(4000).then(() => alert('All done!'));
Add Comment
Please, Sign In to add comment