Skip to content

Instantly share code, notes, and snippets.

@g6ling
Created November 18, 2016 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g6ling/0c312b7cfb50a70d83d01bf9b7e4c025 to your computer and use it in GitHub Desktop.
Save g6ling/0c312b7cfb50a70d83d01bf9b7e4c025 to your computer and use it in GitHub Desktop.
promise chain test 3
var _promise1 = function (param) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
console.log('ok1');
resolve(param);
}, 100);
});
};
var _promise2 = function (param) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
console.log('ok2');
resolve(param);
}, 100);
});
};
var param = true;
_promise1(param)
.then(function (param) {
if (param) {
return _promise2(true)
} return true
}).then(function() {
console.log('ok3')
});
// param === true
// Result
// ok1
// ok2
// ok3
// param === false
// Result
// ok1
// ok3
@voidsatisfaction
Copy link

오케이

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment