为什么构建的版本变量必须声明?预览的就不用?

代码:

        if(!com.isEnemyDead){
            //下面的 num 必须声明才能在构建的版本里正确运行。
            num = this.timeLabel.string - dt;
            num = num.toFixed(3);
            if(num <= 0){
                num = 0;
            }
            this.timeLabel.string = num;
        }

声明就是 var num = this.timeLabel.string - dt;。不声明浏览器控制台会报这个错误:
ReferenceError: assignment to undeclared variable num
奇怪的是在预览的版本是可以正常运行的。