How to check that a function has not received arguments? For example, I want to be able to create a user-defined function that accepts multiple inputs like this:
clear(); // clear all clear('a'); // clear a clear('b'); // clear b clear('c'); // clear c clear('d'); // clear d
You can check if the argument matches undefined :
undefined
function clear(variable) { if (variable === undefined) { ... } }
or just check the number of arguments :
arguments
function clear(variable) { if (arguments.length === 0) { ... } }