support optional params to functions

weird, this is mentioned in the docs but there is no argument for it in the JS, seems like stale documentation?