尝试在javascript中生成消息时出于某种原因解析我的代码中的错误

问题描述

我正在尝试生成随机消息,但是不知何故我的代码中出现了一个解析错误,即即使未定义void也未定义,但将其称为undefined


var a =1
while(a=1){
function alert(message?: any): void}
i have tried using 
GetFileDump=alert(GetFile AnyMessage)
//but that does not work either
//plz tell me what to do

解决方法

尝试

var a = 1;
while (a === 1) {   // a = 1 is not the same as a === 1
  alert("message");
  a = 0;
}
,

强烈建议使用三个比较字符来比较值,这样做是为了防止在比较值时使用不同的数据类型。