Javascript does not officially allows you to declare optional parameter but there is still a way you can handle them. Here we go!
function generateForm(id) { var editable = false; if (arguments.length == 1 && typeof id!= "undefined") { editable = true; } if(!editable) { alert("add form"); } else { alert("edit form"); } }