Skip to content

Instantly share code, notes, and snippets.

@gffcoutinho
Created July 18, 2015 02:36
Show Gist options
  • Save gffcoutinho/0a9d69a4870f85d741a1 to your computer and use it in GitHub Desktop.
Save gffcoutinho/0a9d69a4870f85d741a1 to your computer and use it in GitHub Desktop.
var console = {
log: function( v ) {
var str = (function stringify( obj, unquote ) {
if ( obj === null ) return 'null';
if ( obj === undefined ) return 'undefined';
if ( obj instanceof Array ) {
var str = [];
for ( var i = 0; i < obj.length; ++i ) {
str.push( stringify( obj[i] ));
}
return '[ ' + str.join(', ') + ' ]';
}
var type = typeof obj;
if ( type === 'string' ) {
if ( !unquote ) return '"' + obj + '"';
return obj;
}
if ( type === 'object' ) {
var str = [];
for ( var p in obj ) {
str.push( stringify( p, true ) + ': ' + stringify( obj[p] ));
}
return '{ ' + str.join(', ') + ' }';
}
if ( type === 'function' ) return 'function';
return obj.toString ? obj.toString() : type;
})( v );
WScript.Echo( str );
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment