general utility functions for javascript