Skip to content

Instantly share code, notes, and snippets.

@mosfet1kg
Created July 28, 2015 19:11
Show Gist options
  • Save mosfet1kg/9c1882c57ffa34759ca6 to your computer and use it in GitHub Desktop.
Save mosfet1kg/9c1882c57ffa34759ca6 to your computer and use it in GitHub Desktop.
함수 호출
var Q = require('q');
(function(){
Q.fcall(function(){
return Q.all([
(function(){
var d = Q.defer();
d.resolve('hi');
console.log('test1');
return d.promise;
})(),
(function(){ //function만 있다면 함수를 선언한것 밖에 지나지 않음. 실행을 시키기 위해서 ()()문이 들어감..
var d = Q.defer();
d.resolve('hello');
console.log('test2');
return d.promise;
})(),
temp() //위와는 다르게 함수를 호출했다는 의미임
])
}
).spread(function(){
console.log(arguments);
return;
}).done(function(){
console.log('done');
})
})();
function temp(){
var d = Q.defer();
console.log('test_temp');
d.resolve('a');
return d.promise;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment