Skip to content

Instantly share code, notes, and snippets.

@olslash
Created June 16, 2014 21:11
Show Gist options
  • Save olslash/7c597b939627efc1c7e7 to your computer and use it in GitHub Desktop.
Save olslash/7c597b939627efc1c7e7 to your computer and use it in GitHub Desktop.
Testing the console's representation of data
var externalObj = {key: 'value'};
var items = {
obj: {
'string prop': 'string val',
5: 10,
nested: [[3, [5, 2]]],
'function': function(){return true;},
reference: externalObj
},
arr: [1, 2, 'hi', 'mom'],
str: 'poppler',
bool: true,
inum: 5,
fnum: 3.14159265,
regex: /[a-zA-Z]{3}[0-9]{2}/g,
func: function(){return false;}
};
for (var item in items) {
console.groupCollapsed(item);
item = items[item];
console.log('------ .toString() ------');
console.log(item.toString());
console.log('------ String() ------');
console.log(String(item));
console.log('------ .log(item) ------');
console.log(item);
console.log('------ .log("string " + item)');
console.log('string' + item);
console.log('------ .log("string", item)');
console.log('string', item);
console.log('------ .log(%s, item)');
console.log('%s', item);
console.log('------ .log(%d, item)');
console.log('%d', item);
console.log('------ .log(%i, item)');
console.log('%i', item);
console.log('------ .log(%f, item)');
console.log('%f', item);
console.log('------ .log(%o, item)');
console.log('%o', item);
console.log('------ .log(%O, item)');
console.log('%O', item);
console.log('------ .dir(item)');
console.dir(item);
console.groupEnd();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment