How can I alert an asynchronous function that another instance of the same function has fired?
问题 I am wanting to create an alert inside my function which tracks if any other instances of the same function have fired during a 15 second period. this is what I have so far: bar = 0; async function Counting() { bar += 1; foo = bar; new Promise(resolve => setTimeout(resolve, 5000)); if (bar == foo) { //Do something } else { return; } } I'm using bar as a global counter and foo as a function instance counter, but for some reason all instances of the function update at the same time. How can I