ECMAScript is a family of languages developed for use on the web. The most common of these languages are JavaScript, used by Gecko and Webkit applications; JScript, used in Internet Explorer; and ActionScript, used in Flash. These languages bear a striking resemblance to GraalScript, and in an effort to make code that is more easily ported to and from Flash applications and the web, some features of these languages were added to GraalScript. Below is a summary of some of these features.

Trace

Var

Use of the keyword var in ECMAScript creates a variable whose scope is the body of the function in which it is declared. The var keyword is ignored by the GraalScript compiler, since temp variables already have this property.

Static

Another keyword that is reserved in GraalScript but is unused is static. In ECMAScript, this would bind a function to a class rather than an instance. This behavior can be duplicated in GraalScript, in a way, by using the public qualifier and joining the function to the object (usually a TStaticVar).

Anonymous functions

On the other hand, a function can be bound to an instance rather than a class simply by using an anonymous function.

obj.some_function = function (params) { statements; };

This syntax can be used in GraalScript, although it is somewhat broken. However, anonymous functions in GraalScript are treated as regular functions (with their own separate scope), so while this would display '3' in ECMAScript: