It all starts with
console.log(), however, that is not where it all ends. There is more to the console object than just logging as we will soon discover.
Here are some cool dev tools tricks that use the console.
// regular console.log('Hello!'); // interpolated console.log('Hello i am a %s string!', ':smile:') // styled console.log('%c I am some cool text', 'font-size: 20px; background: blue'); // warning! console.warn('DANGER'); // error console.error('What did you do?'); // info console.info('The sun is hot'); // testing console.assert( 1 === 2, 'That is wrong, revise your math.'); // clearing console.clear(); // viewing dom elements const p = document.querySelector('p'); console.log(p); console.dir();
As you can see from the above code, the console can be a very powerful asset to a developer during development.
Today i learned:
- Various console methods.
- How to output styled text into the console.