Created
June 16, 2014 21:11
-
-
Save olslash/7c597b939627efc1c7e7 to your computer and use it in GitHub Desktop.
Testing the console's representation of data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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