Execute Javascript
- Updated2026-02-04
- 2 minute(s) read
Execute Javascript code. Javascript string evaluation occurs in the context of an anonymous function with one optional string argument Arg. Function executes asynchronously if Wait for Return Value? is FALSE (default) or synchronously if TRUE. When executing synchronously, use the 'return' statement to output a value as Return Value, or 'throw' to output an Exception string. By default, the returned value must be a primitive Javascript type (number, string, bool, or null), which is converted to a string to provide Return Value. If Return Non-primitive Types? is TRUE, the return value can be any Javascript type, and is processed by 'JSON.stringify' to return a string; objects and arrays are encoded as JSON, and string values include surrounding quotes and escaped characters.
Parameters
| Name | Data type | Required | Description |
|---|---|---|---|
| Return Value | ![]() |
No | |
| Exception | ![]() |
No | |
| Javascript String | ![]() |
Yes | |
| Argument | ![]() |
No | |
| Wait for Return Value? | ![]() |
No | |
| Return Non-primitive Types? | ![]() |
No |
Remarks
The following table lists the characteristics of this method.
| Short Name | ExecuteJavascript |
| Data type | No return value |
| Available in Run-Time Engine | Yes |
| Available in Real-Time Operating System | No |
| Settable when the VI is running | Yes |
| Loads the front panel into memory | No |
| Need to authenticate before use | No |
| Loads the block diagram into memory | No |
| Remote access allowed | Yes |


