Js utility functions for use in Stackoverflow and Jsfiddle