javascript check if argument is passed

JavaScript
function func(arg1, arg2) {
  if (typeof arg2 === "undefined") {
    arg2 = "defaultValue";
  }
  
  //Rest of function
}
Source

Also in JavaScript: