Logging Messages (console.log)
To log messages the function console.log
can be used to output messages that will be visible in the dedicated log screen within the application. This is useful for debugging the scripts and monitoring their execution.
Useful to use to get better insight in the execution of the script. Should be used to follow succesfully done steps. Should not be used to print whole documents. Also, make sure to not use it to often to keep messages and progress clear.
Syntax
console.log(message1, message2, ..., messageN);
Parameters
console.log
can accept one or more arguments of any data type. These arguments are evaluated and concatenated into a string or displayed in a structured format in the log screen.
Parameter | Type | Required | Description |
---|---|---|---|
message1, ..., N | Any Type | No (not required but no use without) | One or more values to output to the log screen. |
Return value
console.log
does not return any value. It is used for its side effect of outputting information and finding problems inside of scripts easier.
Example
The following examples show how to use console.log
:
Outputting a simple string
console.log('Script started execution.');
Outputting the value of a variable
let userName = 'Alice';
console.log('Processing user:', userName);
Outputting an object
let userData = { id: 'user123', status: 'active' };
console.log('User data:', userData);