当我尝试使用undefined运行以下动态生成的javascript时,会返回eval()。如果删除if/else语句,它将返回0,但是当我尝试使用if/else语句时,它将返回undefined

function doCalculation() {
    var OfferSupport=0;
    var DOOfferSupport=4;
    var SupportFull=SupportFull;
    var SupportNone=SupportNone;
    if(DOOfferSupport >= 1)
        OfferSupport = SupportFull ;
    else
        OfferSupport = SupportNone ;
    return OfferSupport;
}
console.log('test: ' +  doCalculation());


谁能告诉我为什么?

最佳答案

您要将变量设置为SupportFullSupportNone,这两个变量均未定义。

如果要取回值,则需要设置一个值。

10-05 18:55