How do I get my rocket image to rotate accordingly as the left, right arrows turn its direction??
Also, even if they only use 4 keys, the code will forcefully make the object into a slow dictionary.
Seeing as that object is used multiple times in an interval (
updateGameArea is called in an interval), every iteration may get slower over time, and slower with more key presses.
Oh, and as a bonus, every new key press results in 2 new allocations, furthering my first point.
This is the type of code that will struggle to stay on JiT's fast path, edging on the pathologically slow path.
Creating an empty object creates a hidden class for that object, using a Map or Set uses an already existing class; therefore, that's one less class to store.
(JSC, V8, and SpiderMonkey all do this)
Changing the object structure impacts performance.
JS is always laggy, wdym!?
As for browser support, it has the exact same browser support that
for of loops do.
IE has supported these since... 2013:
Therefore, every single browser still in existence supports these.