let main = document.querySelector('main');
let title = document.querySelector('#title h1');
let panel = document.querySelector('#panel');
let slides = document.querySelectorAll('.slide');
let currentSlide = 0;
let consoles = {
clear: () => {
console.clear();
},
console: () =>{
console.log(console);
},
common: () => {
console.debug('console.debug()');
console.error('console.error()');
console.info('console.info()');
console.log('console.log()');
console.warn('console.warn()');
}
};
let data = [
{
title: 'The Console Object',
button: '<button data-console="console">log the console object</button>',
desc: `<p>The developer’s debugging console has been available in one form or another in web browsers for many years now. Starting out as a means for errors to be reported to the developer, its capabilities have increased in many different ways. Useful features of the console are automatically logging information such as network requests, network responses, security errors or warnings, and more.</p><p>There is also a way for the website’s JavaScript to trigger various commands that output to the console for debugging purposes. These commands are contained in a console object available in almost every browser.</p><pre><code>console.log(console);</code></pre>`
},
{
title: 'Common Usage',
button: '<button data-console="common">common usage</button>',
desc: `<p>We shall start with five commands that at first glance do much the same thing. Which, technically, they do. But the browsers provide additional features tied to the five commands to give each their own distinct benefit.</p><pre><code>console.debug('console.debug()');\nconsole.error('console.error()');\nconsole.info('console.info()');\nconsole.log('console.log()');\nconsole.warn('console.warn()');</code></pre>`
}
];
main.addEventListener('click', e => {
if (e.target.dataset.console) {
consoles[e.target.dataset.console](e);
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.