Javascript utility for working with objects