Debugging Javascript中的布尔错误
有此代码:Debugging Javascript中的布尔错误,debugging,node-red,Debugging,Node Red,有此代码: function checkIsNotOverHeating(context, surchauffe, offset, topic, node){ let msg = null; let overheating; overheating = false; if(checkTemperatureWithOffset(context.get("temperatureInt"), offset, surchauffe, "-") === 1){
function checkIsNotOverHeating(context, surchauffe, offset, topic, node){
let msg = null;
let overheating;
overheating = false;
if(checkTemperatureWithOffset(context.get("temperatureInt"), offset, surchauffe, "-") === 1){
// Overheating
overheating = true;
msg = createMessageOverheat(topic);
}
node.error(overheating)
if(context.get("overheating") !== overheating) context.set("overheating", overheating);
return msg;
}
每个node.error将在节点中输出参数中的值。我无法理解为什么,但它将接受布尔值true,而不是false,正如您在这张图片中看到的:
我使用的是NodeRED,正如您所看到的,代码很简单。每次都会触发我的函数
编辑:不要处理-1,它只会向我显示2值的变化这看起来像是
节点中的一个错误。错误()
代码作为解决方法,请尝试以下操作:
node.error(' ' + overheating);
编辑:
此问题的修复程序已提交:
不,我想不出这个问题。你能澄清一下吗?@Liam在节点RED的上下文中,这是有意义的。我将删除javascript和node.js标记,这应该会有所帮助。我需要再次检查,但我认为这可能是错误函数中的错误。