Javascript utils code snippets