function foo(arg){ if(foo.length !== arguments.length){ throw new Error('Le nombre d\'argument n\'est pas correct'); } } try{ foo('param1', 'param2'); }catch(e){ document.write(e.toString()); //affiche Error: Le nombre d'argument n'est pas correct }