var point = new Array(); var x = new Array(); var artist = new Array(); var num = new Array(); var delta; function sample() { function doubleUp(v) { v=v-10; return v * 2; } function increment(v) { v=4*v; return v + 1; } function output(v) { alert(v); } var pr = Promise.resolve(100); pr .then(increment) .then(doubleUp) .then(output) .catch(function(error){ // promise chain中にエラーが発生した場合に呼ばれる console.error(error); }); }