Created
April 8, 2016 07:59
-
-
Save AlejandroPerezMartin/99de49e2494bac0a231a8155bbcf9a0b to your computer and use it in GitHub Desktop.
JavaScript Promises test
This file contains 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
window.onload = function() { | |
init(); | |
otherFn(); | |
} | |
function init() { | |
var myPromise = new Promise(function(resolve, reject){ | |
setTimeout(function() { | |
resolve("Promise called!"); | |
}, 1000); | |
}); | |
myPromise.then(function (result) { | |
console.log(result); | |
}) | |
.catch(function(reason){ | |
console.error("Rejected because: " + reason); | |
}); | |
} | |
function otherFn(){ | |
console.log("Other code executed"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment