首页 > 回调方式的返回值怎么提取

回调方式的返回值怎么提取

function d() {

        fs.exists(path,function(exists){
            var o= (exists ? "存在" : "不存在!");
            return o;
        });          
        
    }
  return d();  
    
    //我想把o赋值给function d;因为另一个文件需要o的值。
    //上面的return o 不对怎么办。

function d(callback) {

        fs.exists(path,function(exists){
            var o= (exists ? "存在" : "不存在!");
            callback(o);
        });          
        
    }
function a(arg){
    console.log(arg);
}

d(a);
【热门文章】
【热门文章】