Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created November 15, 2012 20:06
Show Gist options
  • Save cowboy/4080907 to your computer and use it in GitHub Desktop.
Save cowboy/4080907 to your computer and use it in GitHub Desktop.
JavaScript: log= (insanity?)
/*
* log= (insanity?)
* http://benalman.com/
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
*/
Object.defineProperty(global, 'log', {
set: function(args) {
console.log.apply(console, Array.isArray(args) ? args : [args]);
}
});
// this is less to type
log='abc';
log=['a', 'b', 'c', 1, 2, 3, true, false];
// than this is
console.log('abc');
console.log('a', 'b', 'c', 1, 2, 3, true, false);
@cowboy
Copy link
Author

cowboy commented Nov 23, 2012

FWIW, don't ever actually do this. It's a horrible idea.

@mischah
Copy link

mischah commented Nov 23, 2012

Better use snippets and the Console API. For instance this: http://mischah.github.com/Console-API-Snippets/

@samccone
Copy link

DSL land here we come

@dcherman
Copy link

log('a', 'b', 'c', 1, 2, 3, true, false); is even less to type by one = char. And more reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment