Created
February 27, 2011 21:47
-
-
Save jasonLaster/846573 to your computer and use it in GitHub Desktop.
WebKit Console tricks adapted from CSS Ninja's excellent tutorial http://bit.ly/fi4lnK
This file contains hidden or 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
<html> | |
<body> | |
<script type="text/javascript" charset="utf-8"> | |
// CONSOLE log | |
var foo = {baz: "tubular", goo: "rad"}, bar = "baz"; | |
console.log("string",1,foo.goo,bar,foo.baz); // string 1 rad baz tubular | |
console.log(foo) | |
// CONSOLE Printf | |
var foo = {baz: "tubular", goo: "rad"}, bar = "baz"; | |
console.log( | |
"%s theory is %d %s concept. I can only describe it as %s and %s", | |
"string", 1, foo.goo, bar, foo.baz | |
); | |
var foo = {baz: "tubular", goo: "rad"}, bar = "baz"; | |
console.log( | |
"%2$d theory is %d %s concept. I can only describe it as %s and %s", | |
"string",1,foo.goo,bar,foo.baz | |
); | |
// 1 theory is 0 baz concept. I can only describe it as tubular and %s string | |
// CONSOLE types of messages | |
console.info("%s numbers %d, %d and %d","hello",1,2,3); // hello numbers 1, 2 and 3 | |
console.warn("%s numbers %d, %d and %d","hello",1,2,3); | |
console.error("%s numbers %d, %d and %d","hello",1,2,3); | |
// log html elements | |
console.dir(document.documentElement); | |
console.dirxml(document.documentElement); | |
// CONSOLE group stuff | |
console.group("overloard"); | |
console.log("overloard stuff"); | |
console.group("Servant"); | |
console.log("Servant stuff"); | |
console.groupEnd('Servant'); | |
console.log('more stuff'); | |
console.groupEnd("overloard"); | |
// CONSOLE TIMING STUFF | |
console.time("Execution time took"); | |
console.group("Timing"); | |
for(var i = 0; i < 1000; i++) {console.log("Minion stuff");} | |
console.groupEnd(); | |
console.timeEnd("Execution time took"); | |
// CONSOLE Assertions | |
function test(a, b) { | |
return a === b; | |
} | |
console.assert(test(1, "1"), "A doesn't equal B"); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment