Console and its various APIs

Monday, September 17, 2018

ES6 tricks


  • Used to clear console


  • To log something on console

Console.time(‘GiveName’) AND console.timeEnd(‘GiveName’)

  • Used to calculate time required to execute code in between console.time and console.timeEnd.
  • It give time in millisecond

console.profile(‘GiveName’) AND console.profileEnd(‘GiveName’)

  • To start profile
  • It shows profile in profile tab with given name

console.assert(expression, message)

  • If the value passed in the first argument is false, the function will log a message given as the second argument in the web console. If the expression is true, nothing is logged.

console.table(object) AND console.table(array,[“name”,”address”]);

  • This function displays the provided object or array as a table
  • You can also restrict table to console only certain property by following way AND console.groupEnd(message)

  • The groups all logs that follow after it until the console.groupEnd()is called to a dropdown list. Lists can be nested.
Sanket Gandhi

Sanket is a Senior Software Engineer with a experience of developing web application. Sanket also enjoys playing games, DIY, watching movies, and tweeting / blogging about his experiences with new web technologies.