Several useful helper functions for JavaScript