I think either we’ll change your initial ad to ...
var offset = {};
... or, your console.log is executed until your function completes. A simple check by adding a log inside a function ...
} else {
offset = doc.offset;
console.log('from inside ... ', offset);
}
});
}
console.log('from outside ... ', offset);
... , "".
EDIT:
"", .
get_time_offset = function(timezone_id){
var offset;
function processResult(val) {
console.log(val);
}
Timezone.findById(timezone_id, function(err, doc){
if(err) {
console.log(err);
} else {
offset = doc.offset;
}
processResult(offset);
});
}