I'm making a simple game with javascript that you can fire bullet to enemies. Actually I don't have any problem making it but:
I made a class for my bullets that it has a Move function and I want to set an interval for it but when I set an interval in my constructor like this:
setInterval(this.Move, 0);
I see this error:
uncaught TypeError: Cannot read properties of undefined (reading 'style') at Move (game.js:152)
But when I set and inverval like this:
setInterval(() => {
this.Move();
}, 0);
It works without any problem.
I just what to know what is wrong with first one, I think the second way, you're making an extra thing (lambda expression).
Bullet Class: https://i.stack.imgur.com/q23Lk.png