Technically passing in null would be calling it with two arguments so your example doesn't exactly represent that anyway. If you want an answer that's safe for arrow functions as well (they don't have the arguments object) you could just check to see if the second argument is a number. This would catch a lot of it.
function divide(num1, num2) {
if (typeof num2 !== 'number') return null;
return num1 / num2;
}
If you wanted to handle the edge case that the first passed argument was undefined you could check both arguments.
function divide(num1, num2) {
if (typeof num1 !== 'number' || typeof num2 !== 'number') return null;
return num1 / num2;
}
If you want to get fancy it could be a one line arrow:
const divide = (num1, num2) => typeof num2 !== 'number' ? null : num1 / num 2;