Arrays vs. Mappings

Learn the differences and similarities between arrays and mappings in Solidity.

Arrays and mappings are two ways of storing complex data in Solidity. Each comes with advantages and disadvantages.

Differences between arrays and mappings

We can loop through arrays using for and access an element in an array using the zero-based index of the element. We can’t do these things with mappings. As we’ve learned, arrays in Solidity have push member functions to add, but unlike in JavaScript, there are no filter or find functions. This means that to access a ...