↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Like `console.log` But Better

The page says the console offers more than log and that these methods can make debugging less confusing. It highlights ways to display data more clearly, count calls, check assertions, and style log output.

Reading notes
#

  • console.table() shows arrays and objects in a table, with rows for elements or properties and optional column names.
  • console.count() keeps track of how many times it has been called, and a string label can be provided.
  • console.assert() only writes to the console when the assertion is false, using the second argument as the error message.
  • Labels can be added to console.log() by passing a string first, which helps organize the output.
  • %c can be added to the first string in console.log() and CSS styles can be passed as the next argument to color and style the message.