JSFiddle - React, Tailwind, and code Playground
JavaScript
var myFunc = function (x) {
if (typeof x === 'undefined') {
return 'no args';
} else if (typeof x === 'function') {
return x();
} else if (arguments.length === 1) {
return 'x was ' + x;
} else {
return arguments.length - 1 + ' extra arguments provided';
}
},
result1 = myFunc(),
result2 = myFunc(function (y) { console.log(y); }),
result3 = myFunc(statement),
result4 = myFunc(1),
result5 = myFunc({}, true, 'text');
console.log(result1, result2, result3, result4, result5);
function statement(x, y, z) {
console.log(x, y, z);
}