Execute js code

Description

Enables you to write and execute a JavaScript code. All variables created inside this block will remain local. Global variables can be used and modified inside this block.

Parameters

Statement

Contains a JavaScipt code to be executed. For example:

function calc(a, b) {
return a + b - a*b;
}
var num1 = 10;
var num2 = 15;
//Variables result и arr are global - created outside the block
result = calc(num1, num2);
arr.push(result);
arr[4] = 18;

Comment

Contains an annotation to the block. The input text will be displayed inside the block above the function name.

Usage Examples

This function is suitable in situations where there is no need to save a result in a variable but still some code is to be executed. For example, the pushmethod returns an array length and changes the array. If you don't need to save the array length then using the 'Change variable' function is easier then using the 'Assign value to variable' function.

Also this function is useful for writing some parsing algorithms as blocks are not very comfortable for these purposes.