24
In JavaScript Console Other Than Console.log()
- Console.count()
Let assume you want to keep a count of how many click the user makes on the button. The code with .log() might look like this
let userClickCounter = 0;
function watchUserClicks(){
userClickCounter++;
console.log("User Clicked ${userClickCounter}")
}
<button onclick = "watchUserClicks()">
Click Me to Without pause
</button>
The other method is also present
function watchUserClick(){
consol.count('User Click');
}
<button onclick = "watchUserClicks()">
Click Me to Without pause
</button>
Here the need for variable and its related code is eliminated thereby, making the code optimal and readable.
- Console.Dir()
This method shows all the properties of the JS Object.
The console.log() print out toString representation whereas consol.dir() print out a navigation tree
see the difference:-
- Console.Time() and Console.ThimeEnd()
When you are working on a complex algorithm. time is one of the main factor you need to look on simultaneously.
this is where you can use these console method to know how much time your algorithm is taking to execute.
- Console.table()
24