我有以下功能......
If(signInSet(sign_in_data)){
do something... //appends data to a variable that is outputted after the if statement
}
else{
do something else...
}
则...
signInSet(sign_in_data){
var equal = false;
$.get('url', function(currentDate){
$.each(sign_in_data, function compareDate(){
if(this.date === currentDate){
equal = true;
return false; //to end the each loop
}
});
//at this point i can see and print out the value of equal
});
我对这个函数的异步性有一些了解,我想知道如何重构我的代码以便能够看到相等的值,所以我可以在我的if语句中使用它。提前致谢。