Example 6-11. Managing asynchronous image loading using a promise


loadImage('thesis_defense.png').then(function (img) {
	console.log('received image');
}).catch(function (e) {
	console.log('Error occurred while loading image');
	console.log(e);
});