https://peterkellner.net/2015/11/21/using-map-instead-of-for-in-javascript/