即使没有正确的设置变量,脚本如何继续运行?感谢您的回复!无回调设置变量
代码
function get(param) {
// Connect to database and get the response ~ 1 sec
db.get(param, function(output) {
console.log("Hey, I set the variable!");
return output;
});
}
try {
var username = get("username");
var birthday = get("birthday");
} catch (e) {
error = e;
}
if (!error) {
console.log("No errors? Everything all right?");
}
输出
No errors? Everything all right?
Hey, I set the variable!
我想有一堆你没有向我们展示的代码。 – Pointy 2010-11-25 21:56:55