Some useful functions for javascript.