Another example of use promises with native JS. Actually I'm using promises in Angular or node.js.
var count = 0;
function testPromice() {
var promiseCount = ++count;
var p1 = new Promise(function(resolve, reject){
window.setTimeout(function() {
resolve(promiseCount)
}, Math.random() * 3000 + 1000);
window.setTimeout(function
(
Read more... )