4 ms·
The solution to this and similar problems is to define more protocols like the iteration protocol [1], but for showing objects, accessing their properties etc.
by spion 11y ago
The solution to this and similar problems is to define more protocols like the iteration protocol [1], but for showing objects, accessing their properties etc.
If libraries and tools rely on protocols instead of using built-in objects then we would be able to plug any kind of data structure implementing the required protocols into any kind of library that takes advantage of those protocols.
[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...