Answers for "javascript check if argument is passed"

1

javascript check if argument is passed

function func(arg1, arg2) {
  if (typeof arg2 === "undefined") {
    arg2 = "defaultValue";
  }
  
  //Rest of function
}
Posted by: Guest on May-22-2020
0

javascript check if argument is passed

function addition(arg1, arg2) {
			if (typeof arg1 === "undefined" || typeof arg2 === "undefined") {
				arg3 = "Please Give Me Default Value";
				document.write(arg3);
				console.log(arg3);
			} else {
				var arg1;
				var arg2;
				var arg3 = arg1 + arg2;
				document.write(arg3);
				console.log(arg3);
			}
		}
Posted by: Guest on September-24-2021

Code answers related to "javascript check if argument is passed"

Code answers related to "Javascript"

Browse Popular Code Answers by Language