3 ms·
JavaScript also has Map. Which is more general since the keys don't have to be strings.
by thayne 4y ago
JavaScript also has Map. Which is more general since the keys don't have to be strings.
- voidfunc 4y agoKeys do not need to be strings in Java either, you need to properly implement equals and hashCode() methods though for the key type. Also Java has like ten different implementations of Map<K,V> depending on various use cases.
- thayne 4y agoI wasn't comparing to Java. I was commenting on > Javascript: Object And in javascript, if you use an Object as a map, the keys do have to be strings (if they aren't already, they are converted into strings).