【发布时间】:2011-08-30 05:43:36
【问题描述】:
regular = 'a string';
enriched = enrichString(regular);
sys.puts(enriched);
function enrichString(str){
//run str through some regex stuff or other string manipulations
return str;
}
现在它似乎正在做我希望它会做的事情,但我不知道它是否安全。这有时会导致未定义吗?我需要做类似的事情吗:
regular = 'a string';
enriched = enrichString(regular, function(data){sys.puts(data);});
function enrichString(str, cb){
//run str through some regex stuff or other string manipulations
cb(str);
}
感谢您的帮助!
【问题讨论】:
标签: javascript jquery asynchronous node.js callback