Console Tips and Tricks
Here are some quick commands for the console.
Getting to the console in your browser
Press F12 and Find the console tab.
That little blue > there is the console. this is in brave or chrome, but on different browsers the shortcut to get there may be in settings.
What can we do in the console?
The most common thing to do here is check for script errors, but you can do tons more things like run javascript functions or anything the browser is capable of if you know the commands.
Test some variables
Log some variables to the console.
Javascript
var test = 10;
var another_test = "kruxor";
console.log(test);
console.log(another_test);
Log as an object to see the variable name and value by adding {} to the variable name.
Javascript
console.log({test});
console.log({another_test});
Example Console Result
Or you can just log them all together creating a single object.
Javascript
console.log({test}, {another_test});
Example logging multiple objects in one log.
You can then use the console.table to show the data in a tabular format rather then just the raw objects.
Javascript
console.table({test});
console.table({another_test});
Example of console.table result.
Other types of console messages
Here are some other message options in red and orange and just normal console message format.
Javascript
console.log("This is a log message") // normal log
console.info("This is information") // another way to do a standard display
console.error("This is an error message") // highlight the message in red and flag it as an error
console.warn("This is a warning") // highlight the message in orange and flag it as a warning
Example console messages
Javascript
// Log some variables to the console.
var test = 10;
var another_test = "kruxor";
console.log(test);
console.log(another_test);
// Log this as an object so you can see the variable name and value.
// just add some curly bracers to the main variable name.
console.log({test});
console.log({another_test});
// Or you can just log them all together creating a single object.
console.log({test}, {another_test});
// You can then use the console.table to show the data in a tabular format rather then just the raw objects.
console.table({test});
console.table({another_test});
// Other types of console messages.
console.log("This is a log message") // normal log
console.info("This is information") // another way to do a standard display
console.error("This is an error message") // highlight the message in red and flag it as an error
console.warn("This is a warning") // highlight the message in orange and flag it as a warning