When is the last time you use console.log method to debug your javascript code? Maybe just a minute ago, one hour ago or might one week ago. All of us here are very familiar with console.log but do you know that besides that method, we still have other great methods belong to
Take a quick look on

In this post we will run thought each of them
console.assert
Syntax
console.assert(assertion, msg [, subst1, ..., substN]);
Parameters
assertion | Any boolean expression. If the assertion is false, the message is written to the console. |
msg | A JavaScript string containing zero or more substitution strings. |
subst1
…
substN
| JavaScript objects with which to replace substitution strings within
msg
. This parameter gives you additional control over the format of the output. |
Usages
This utility helps us to write out the error messages only when under the assertion. The message is only printed out when the value of assertion is false, otherwise, nothing happens. We can gain the same effect with the combination of “if” statement and “console.error”. But console.assert is a more elegant way which could save us some typing:


This utility is extreme useful when we deal with a loop, we only print out the message in specific turns to avoid flooding the entire window with our error message.
console.clear
Syntax
console.clear()
Usages
Use to clean up the current console window when there are a lot of messages that are not used anymore, we can archive the same result with “ban-circle” ⃠ button, but with


console.count & console.countReset
Syntax
console.count([label]); console.countReset([label])
Parameters
label | If supplied,
count()
outputs the number of times it has been called with that label. If omitted,
count()
behaves as though it was called with the “default” label. |
Usages
console.count helps us to count how many time a block of code is executed, how many turns the loop runs or how many time the event is triggered. In addition, console.countReset helps us to start over the counting

console.info & console.debug & console.warn & console.error
Syntax
console.info(assertion, msg [, subst1, ..., substN]); console.debug( msg [, subst1, ..., substN]); console.warn( msg [, subst1, ..., substN]); console.error( msg [, subst1, ..., substN]);
Parameters
msg | A JavaScript string containing zero or more substitution strings. |
subst1
…
substN
| JavaScript objects with which to replace substitution strings within
msg
. This parameter gives you additional control over the format of the output. |
Usage
These 4 methods are used when we want to print out the message on

Console.dir & console.dirxml
Syntax
console.info(assertion, msg [, subst1, ..., substN]); console.debug( msg [, subst1, ..., substN]); console.warn( msg [, subst1, ..., substN]); console.error( msg [, subst1, ..., substN]);
Parameters
msg | A JavaScript string containing zero or more substitution strings. |
subst1
…
substN
| JavaScript objects with which to replace substitution strings within
msg
. This parameter gives you additional control over the format of the output. |
Usage
These 4 methods are used when we want to print out the message on
Console.group & console.groupCollaped & console.groupEnd
Syntax
console.info(assertion, msg [, subst1, ..., substN]); console.debug( msg [, subst1, ..., substN]); console.warn( msg [, subst1, ..., substN]); console.error( msg [, subst1, ..., substN]);
Parameters
msg | A JavaScript string containing zero or more substitution strings. |
subst1
…
substN
| JavaScript objects with which to replace substitution strings within
msg
. This parameter gives you additional control over the format of the output. |
Usage
These 4 methods are used when we want to print out the message on
Console.dir & console.dirxml
Syntax
console.info(assertion, msg [, subst1, ..., substN]); console.debug( msg [, subst1, ..., substN]); console.warn( msg [, subst1, ..., substN]); console.error( msg [, subst1, ..., substN]);
Parameters
msg | A JavaScript string containing zero or more substitution strings. |
subst1
…
substN
| JavaScript objects with which to replace substitution strings within
msg
. This parameter gives you additional control over the format of the output. |
Usage
These 4 methods are used when we want to print out the message on
console.memory
Syntax
console.info(assertion, msg [, subst1, ..., substN]); console.debug( msg [, subst1, ..., substN]); console.warn( msg [, subst1, ..., substN]); console.error( msg [, subst1, ..., substN]);
Parameters
msg | A JavaScript string containing zero or more substitution strings. |
subst1
…
substN
| JavaScript objects with which to replace substitution strings within
msg
. This parameter gives you additional control over the format of the output. |
Usage
These 4 methods are used when we want to print out the message on
console.profile & console.profileEnd
Syntax
console.info(assertion, msg [, subst1, ..., substN]); console.debug( msg [, subst1, ..., substN]); console.warn( msg [, subst1, ..., substN]); console.error( msg [, subst1, ..., substN]);
Parameters
msg | A JavaScript string containing zero or more substitution strings. |
subst1
…
substN
| JavaScript objects with which to replace substitution strings within
msg
. This parameter gives you additional control over the format of the output. |
Usage
These 4 methods are used when we want to print out the message on
console.table
Syntax
console.info(assertion, msg [, subst1, ..., substN]); console.debug( msg [, subst1, ..., substN]); console.warn( msg [, subst1, ..., substN]); console.error( msg [, subst1, ..., substN]);
Parameters
msg | A JavaScript string containing zero or more substitution strings. |
subst1
…
substN
| JavaScript objects with which to replace substitution strings within
msg
. This parameter gives you additional control over the format of the output. |
Usage
These 4 methods are used when we want to print out the message on
console.time & console.timeEnd & console.timeLog & console.timeStamp
Syntax
console.info(assertion, msg [, subst1, ..., substN]); console.debug( msg [, subst1, ..., substN]); console.warn( msg [, subst1, ..., substN]); console.error( msg [, subst1, ..., substN]);
Parameters
msg | A JavaScript string containing zero or more substitution strings. |
subst1
…
substN
| JavaScript objects with which to replace substitution strings within
msg
. This parameter gives you additional control over the format of the output. |
Usage
These 4 methods are used when we want to print out the message on
console.trace
Syntax
console.info(assertion, msg [, subst1, ..., substN]); console.debug( msg [, subst1, ..., substN]); console.warn( msg [, subst1, ..., substN]); console.error( msg [, subst1, ..., substN]);
Parameters
msg | A JavaScript string containing zero or more substitution strings. |
subst1
…
substN
| JavaScript objects with which to replace substitution strings within
msg
. This parameter gives you additional control over the format of the output. |
Usage
These 4 methods are used when we want to print out the message on