JSFiddle - React, Tailwind, and code Playground
by Ivo Tanev
HTML
<div>
</div>
CSS
div {
font-size: 16px;
font-family: sans-serif;
}
JavaScript
d = $('div');
function log(text) {
var date = new Date();
var strt = date.getMinutes() + ':' + date.getSeconds() + '\'' + date.getMilliseconds();
d.append($('<p>').text((strt + ': ' + text)));
}
function as() {
var defer = $.Deferred();
setTimeout(function() {
log('as timeout executed.');
fn(function() {
log('entered fn callback.');
});
}, 3000);
function fn(callback) {
setTimeout(function() {
log('entered fn timeout.');
callback();
defer.resolve(1, 2);
}, 2000);
}
return defer.promise();
}
as()
.then(function(first, second) {
log('as().then executed');
})
.done(function() {
log('as().done executed');
});