| Function | Description |
| JS.eval | Evaluates JavaScript in the global execution context. |
| JS.getValue | Converts a JavaScript variable or property to its CSPro equivalent. |
| JS.getValueJson | Returns the JSON representation of a JavaScript variable or property. |
| JS.hasValue | Returns whether a JavaScript variable or property is defined (not undefined). |
| JS.invoke | Executes a JavaScript function that exists in the global execution context with any CSPro arguments converted to their JavaScript equivalents. |
| JS.setValue | Converts a CSPro variable to its JavaScript equivalent and adds this as a variable to the global scope, or sets an object's property. |
| JS.setValueFromJson | Create a JavaScript variable using JSON and adds it as a variable to the global scope, or sets an object's property. |
When executing JavaScript from CSPro logic, any uncaught exceptions will be displayed as error messages.
JS.eval("const artist = 'Roberta Flack';"); // undefined
JS.eval("artist.toUpperCase();"); // ROBERTA FLACK
JS.eval("[ ...artist ];"); // R,o,b,e,r,t,a, ,F,l,a,c,k
function sumArray(values) {
let sum = 0;
// use forEach to sum the values of an array
values.forEach(value => {
sum += value;
});
return sum;
}
Array someNumbersArray(4) = 10, 20, 30, 40;
List someNumbersList = 4, 6, 7, 79, 81, 82;
JS.invoke("sumArray", someNumbersArray); // 100
JS.invoke("sumArray", someNumbersList); // 259