Better Javascript snippets

Added a few more useful snippets (mostly functions with the option to use arguments).

I also went with saner defaults for the 'for' loop.