我的功能如下:
function isAttachedDataChanged(){
if(attachedDataOld != interaction.attachedData){
console.log("VARIABLE IS CHANGED");
}
}
我像这样运行这个函数,运行后我用新值设置attachedDataOld
:
isAttachedDataChanged();
attachedDataOld = interaction.attachedData;
当我第一次运行attachedDataOld
为空时,它是好的,但是当我下次运行时attachedDataOld
设置的不是先前的值而是具有当前值。所以它的工作方式如下:
首先要做到这一点:attachedDataOld = interaction.attachedData;
接着这样做:isAttachedDataChanged();
答案 0 :(得分:0)
好吧,假设您的脚本正在启动,其调用isAttachedDataChange(),未设置attachmentDataOld,您的函数end和attachedDataOld等于interaction.attachedData。你第二次期望你的函数被称为if语句返回true?您已设置attachedDataOld = interaction.attachedData。