[英]How can I check if a global variable that defined in Node.js if it's not changing after seconds
I wrote an app in nodejs but having logic problem with variable.我在 nodejs 中编写了一个应用程序,但变量存在逻辑问题。 I'm looking for help with this issue.
我正在寻求有关此问题的帮助。
Well, i have a global integer variable named "global_something" I need a function that check if "global_something" not changing after 1000ms or 2000ms好吧,我有一个名为“global_something”的全局整数变量我需要一个函数来检查“global_something”在 1000 毫秒或 2000 毫秒后是否没有改变
How i can do that ?我怎么能这样做?
Thanks!谢谢!
You have to make 2 variable for that你必须为此创建 2 个变量
var original_global = 'Test';
var copy_original_global; // save this field in database or json file for compare
setInterval(()=>{
if(!copy_original_global){
copy_original_global = original_global;
return
}
if(original_global != copy_original_global){
console.log('Changed')
}
}, 3000);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.