Sunday, December 5, 2021

Lookup map in JavaScript

Hey guys! Do you know if statement? Of course yes! But do you know lookup map? It's an elegant way to solve a multiple conditions.

Instead of using if..else, switch, we can define in advance a lookup table of values based on certain key.

Let's look at an example:

No comments:

Post a Comment