Augmenting JavaScript with some useful functions