Обещания.
console.log('some piece of code');
examplePromise.then(function(result){
console.log(result);
}).catch(function (error) {
console.error(error);
});
console.log('another piece of code');
Blue Beetle