21
loading...
This website collects cookies to deliver better user experience
console
which gives us the ability to access the browser's debugging console. If you have ever worked with javascript you must have used it with its log
property. But it is not limited to that, try running the below commandconsole.log(console);
log()
.console.log('foo');
console.log(10);
console.log(null);
console.log(undefined);
console.log(['foo', 'bar']);
console.log({ foo: 'hello', bar: 'hi' });
console.table(['foo', 'bar']);
console.table({ foo: 'hello', bar: 'hi' });
console.error('You Have Got An Error');
console.warn('You Have Got A Warning');
let obj = { name: 'Sam', age: '20' };
console.assert(obj['birth'], `obj doesn't contain birth key`);
count()
is called.console.count('foo');
console.count('foo');
console.count('bar');
console.count('bar');
console.count('bar');
console.group()
and to define the end, use console.groupEnd()
.console.log('Outer Log');
console.group('Outer Group');
console.log('Level 1');
console.group('Inner Group');
console.log('Level 2');
console.error('Level 2');
console.groupEnd();
console.log('Level 1');
console.groupEnd();
console.time('label')
and to stop the timer, use console.timeEnd('label')
. Remember to use the same label in both time()
and timeEnd()
.console.time('time');
let i = 0;
while (i < 100000) {
i++;
}
console.timeEnd('time');
const func1 = () => {
const func2 = () => {
console.trace();
};
func2();
};
func1();
console.log(
'%cWebBrainsMedia',
'background-color: black; color: orange; font-style: italic; font-size: 2em; padding: 10px;'
);