# Running JavaScript against messages using a function node

You can run JavaScript against messages to perform various functions, e.g.:

- Modifying messages
- Creating new messages
- Handling errors
- Storing data

1. Open Node-RED.
2. Add a function node from the function category to the workspace.
3. Double-click the function node to open the Edit node dialogue.
4. In the Function text box, specify the JavaScript code.
5. With the Outputs spinner, select the number of outputs.

6. The JavaScript code must return an array of messages to serve multiple outputs. If an element of that array is again an array of messages, multiple messages are send through the corresponding output.

7. Click Done to apply your changes.
8. Connect the input of the function node to the node that outputs the messages you want to run JavaScript against.