var user = {
get: function() {
return new Promise(function(resolve, reject) {
setTimeout(resolve, 1000);
});
},
set: function() {
return new Promise(function(resolve, reject) {
setTimeout(resolve, 2000);
});
}
};
user.get().then(function() {
console.log(new Date(), "get");
}).then(function() {
console.log(new Date(), "set");
});
Promise.resolve('Hello world').then(console.log).then(console.log);