callback

function loadImage(src, parent, callback){
	var img = document.createElement('img');
	img.src = src;
	img.onload = callback;
	parent.appendChild(img);
};
var sequence = get('example.json')
.then(doSomething)
.then(doSomethingElse);

Syntax

var promise = new Promise(function(resolve[, reject]){
	var value = doSomething();
	if (thingWorked){
		resolve(value);
	} else if (somethingWentWrong){
		reject();
	}
}).then(function(value) {
	return nextTing(value);
}).catch(rejectFunction);