var i = 0; function a(callback){ i +=1; callback(i); }; setInterval(a((num)=>{ console.log(num); }),1000);
The above is the code I made. I expected that it would come out as 1, 2, 3... every second, but with the error TypeError: "callback" argument must be a function, only 1 is printed and finished.
Why is this happening?
node.js callback
setInterval()
The first factor that the function receives should be a function, but it contains the contents of the function. It works by enclosing a((num)=>{ console.log(num);})
with an anonymous function.
796 GDB gets version error when attempting to debug with the Presense SDK (IDE)
1338 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
833 Error in x, y, and format string must not be None
915 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2025 OneMinuteCode. All rights reserved.