filmov
tv
Creating a keyboard events manager in JavaScript, without using switch or if..else-if statements

Показать описание
A friend of mine asked me if there was a better way to handle keyboard events without having to resort to a switch statement or a nasty if..else-if hell. I decided to make a video to demonstrate to him how this can be achieved with a standard object and just a single if-else statement. The beauty of this approach is that getting to the complexity required to access a specific event's handler is always equal to the time complexity required to access object(hash map) properties, which usually is O(1).
Voice version to follow :)
Voice version to follow :)