miscellaneous JavaScript utility functions