JavaScript utility functions