This example is an equivalent of HelloWorldExample.cpp written entirely in JavaScript. It can be run as a separate program with ScriptRunner or executed as a script through Scripting::JSContext.
The difference between C++- and JavaScript-version is that in JavaScript one doesn't have to initialize MultiWidgets::Application, since it is automatically constructed, initialized and started. So the only thing that is left for for the programmer is to create and position the widgets.
Inside the loop we first create new Widget. Note that C++-namespaces are transformed to the global JavaScript-objects.
After this the created widget is added to the child of the main layer of application. The application is accessed through $-object as its member variable app.
The rest of the loop body just sets the size, position and color of the widget. The full source code is shown below: