如何确保值填充到变量中?

How to ensure values are populated in the variables?

如何放置 if 语句来检查我的变量是否已填充?我的代码工作正常,但我想在未从数据库中检索值的情况下进行这些检查。然后我可以相应地处理事情。

提前感谢您的关注

var thisFunction = function(callback) {
  var valueToRetrieve = Meteor.user().profile.temp.valOne
  var valueToRetrieveAsWell = Meteor.user().profile.temp.valOne
  callback(null, {a: valueToRetrieve, b: valueToRetrieveAsWell})
}

var thisFunctionSync = Meteor.wrapAsync(thisFunction)
if (valueToRetrieveAsWell != undefined) { }
or
if (typeof valueToRetrieveAsWell !== "undefined") { }

这个??我不太确定你要什么

if(!variabe){ //no variable
//run some code
}else{
//if there is a variable run more code
}