I'm going to start a series of posts about Javascript with some Patterns to share knowledge.
Here's the first Pattern.
The Indexing Pattern is a design pattern that allows easy access to elements in a data collection using a numeric index. In JavaScript, arrays are one of the most common data structures that use the indexing pattern, but we can also use literals, Maps, Sets, Classes with Static Attributes, etc.
It's common that when comparing arrays, we often increase the spatial complexity of the code...
The ideal way to handle this is to use this Pattern. Viable options are Literals, Maps or Classes with Static Attributes.
With this, we can reduce spatial complexity, which can scale exponentially when we chain for loops.
Top comments (0)