Console methods
assert
Outputs an error message to the console if the assertion is false. If the assertion is true, nothing happens.
clear
Clears the console, removing all previous messages.
count
Logs the number of times that this particular call to count()
has been called with the given label.
countReset
Resets the count for the specified label.
debug
Outputs a message to the console with a low priority, similar to log
, but can be filtered differently based on the console's settings.
dir
Displays an interactive list of the properties of the specified JavaScript object. This list lets you explore the object in a structured format.
dirxml
Displays an XML/HTML element representation of the specified object if possible.
error
Outputs an error message to the console, typically used for logging error messages.
group
Creates a new inline group in the console. Subsequent messages will be indented by an additional level, until groupEnd
is called.
groupCollapsed
Similar to group
, but creates a collapsed group which can be expanded by the user.
groupEnd
Exits the current inline group.
info
Outputs an informational message to the console, similar to log
, but can be styled differently by the console.
log
Outputs a general message to the console. This is the most common method used for logging general information.
profile
Starts recording a performance profile. This profile can be used to analyze performance issues.
profileEnd
Stops recording a performance profile.
table
Displays data as a table in the console, making it easier to view and analyze array or object data.
time
Starts a timer with a specified label. This timer can be used to measure how long an operation takes.
timeEnd
Stops the timer started with time()
and logs the elapsed time to the console.
timeLog
Logs the current value of the timer created with time()
without stopping it.
trace
Outputs a stack trace to the console, which can be useful for debugging to see the path taken to reach a certain point in code.
warn
Outputs a warning message to the console, typically used for logging warnings or potential issues.
Thank you for taking the time to read this article. Hopefully, this has provided you with insight to assist you with your business.