变量重置为默认选项,WHY
Variable reset to default option, WHY?
我不明白为什么我在变量被分配一个数字后总是以"null"结束。
function evalKayScript(syn){
coms = extract(syn,"{...}");
document.write(JSON.stringify(coms));//debug
for(x in coms){
ops = extract(coms[x],"(...)");
com = null; //<-- ***com preset null***
for(y in funNames){
if(ops[1] == funNames[y]){
com = y; //<-- ***com changed to "y"***
}
}
alert(com); <-- alerts given below (first two alerts)
if(com == null){
alert("Command ((("+ops[1]+"))) Not Registered!");
return null;
}
exe = funValues[y];
inputs = execVars(ops[2]);
inputs = extract(inputs,"[...]");
for(y in inputs){
exe.replace(new RegExp("/'('%"+y+"'%')/gim"),inputs[y]);
}
exe.replace(new RegExp("/'('%name'%')/gim"),ops[0]).replace(new RegExp("/'('%function'%')/gim"),ops[1]);
exea = exe;
if(exe.replace(new RegExp("/':':':javascript/gim"),"")! = exes){ //<-- new invalid ":" error
eval(exe);
}else{
evalKayScript(exe);
}
}
}
我不明白为什么,变量"com"变成了一个数字,然后又变成了null…我已经设置了一些错误捕获在我自己的形式,我结束了这些警告:
0 //<-- var com
null //<-- ***var com? this makes no sense, how does it go back to null?***
Command ((("(%name%) already exists!"))) Not Registered! //<--caused by if(com == null) This is normal.
实时脚本位于http://jstone88.bugs3.com/kayscript/file1.html, JS文件位于http://jstone88.bugs3.com/kayscript/kayscript.js
您没有使用RegExp
构造函数,因为它应该被使用。
是这样的:
new RegExp("pattern without / at the beginning an end","flags");
/pattern/flags
是js中regex的文字形式,但在RegExp构造函数中是不同的。
相关文章:
- 我的单元测试选项是什么
- 如何更改bigquery API中的计费层选项
- 使用Javascript获取所选选项ID
- Selectize.js:如何对整数值的选项进行排序
- 通过js在新选项卡中有条件地打开url
- 按照选项卡索引的顺序循环一个jQuery选择
- 如何在使用selectBoxIt JQuery插件时检测选项更改
- 无法在Ionic select中预先选择最后一个选项
- 如何在选项卡上定义属性'的主窗口对象
- 为什么grunt contrib connect的中间件选项的第三个参数是未定义的
- 使用此选项选择父类内部的类
- CKeditor:更改对话框中的默认选择选项
- JQuery覆盖不更改单选选项
- 活动选项卡's源代码-获取变量s值
- 绑定时将Parsley minlength消息作为选项传递时,未对其进行自定义
- 如何从选择框中的选项中获取属性值
- 如何在从多选下拉列表中选择选项值时动态生成文本框
- React Native通过Navigator将用户输入数据传递到选项卡栏IOS中的组件
- 如何从外部页面激活非默认引导选项卡
- 变量重置为默认选项,WHY