how to dump arguments of this function to the browser console

a simple code snippet to dump the arguments of this function to the browser console:

 //dump args to console:  
 var msg = '';  
 for (var i = 0; i < arguments.length; i++) {  
   msg += arguments[i] + ', ';  
 }  
 console.log('xxx MyFunctionName() - ' + msg);  

a more generic approach: (but output is not as tidy)
 //note: arguments.callee.name will be empty for a function expression  
 console.log(arguments.callee.toString().substr(0, 80) + '...' + ' - ' + JSON.stringify(arguments));  

Comments