Once upon a time I ad an assignment task on one of interviews that hasn't been giving me to sleep since:
Need to log a arguments
-object in console
in one line with a date in the end. As objects(to be able to inspect those), not string( Array prototype.join()
- is not a solution in this case)
a fail attempt(out of function scope):
var fn = function () {
var arr = Array.prototype.slice.call(arguments);
arr.push(new Date().toJSON());
Function.prototype.call.apply( console.log, arr );
}
fn( 1, 'a', [2, 3], {a:1} );
logs:
Uncaught TypeError: Illegal invocation
Any ideas?