A typical Notch JS script can have these types of components:


Global variables These can be used for passing values in and out of the Javascript node. You define the input and output global variables you want to hook in the Javascript Node. You can have non hooked global variables as well.
Update() function called by Notch every frame.
OnKeyPress() function called by Notch when a key is pressed.

All these elements are optional and not required in a script.

Notch will run the script when it loads, so you can initialize elements when you first start.

var inputA, inputB, outputA, outputB;

function initialize() 
{ 
    Log("My Script v0.1");
    // Initialize any *internal* variables here.
}

function Update() 
{ 
    // Put your active code in here.       
}

function OnKeyPress(key)
{
    // Respond to keypresses here
}

initialize();

However, your javascript might be as light as:

var inputA, inputB, outputA;

function Update()
{
    outputA = inputA + inputB;
}