# JavaScript

Runs user-defined JavaScript code in the processing pipeline.

## Inputs

The inputs of the tool are defined by the inputParameters parameter. Input values can be accessed in the script code through an object called "$i" in the global scope. For example, if there is an input parameter called "input", its value is stored in "$i.input".

inputParameters
A table that defines input parameters. The first column contains the name of a parameter, the second one its type (optional/required/fixed) and the third one the data type of the parameter's value.
outputParameters
A table that defines output parameters. The first column contains the name of the parameter, the second one is type (synchronous/asynchronous) and the third one the data type of the parameter's value.
code
JavaScript code to be run. Assume the names of input parameters are "operand1" and "operand2", and that there is a single output parameter called "sum". The code of a tool that calculates the sum of the two operands could be written as follows:
stateEnabled
Whether the script code supports state variables or not. It may have a slight impact on performance, so if the script does not need state variables, it is advisable not to enable this parameter.