export (Statement)

Exports some properties to allow them to be imported into another execution context.


ECMAScript edition - 2
JavaScript - 1.2
Netscape - 4.0
Netscape Enterprise Server - 3.0
JavaScript syntax:Nexport aFunction;
Nexport aProperty;
Argument list:aFunctionA function object to export
aPropertya named property

ECMAScript edition 2 suggests this is a future extension. As of the third edition of the ECMAScript standard it is still denoted as a reserved word.

Netscape 4 anticipates that a future standard will endorse this capability and provides it anyway.

This functionality allows layers to define handlers for themselves and then export them to allow other layers or windows to call them.

This facility is also useful to allow controlled access via the security policy. This can then allow an unsigned script to have access to content in a signed script's context.

This is good Object Oriented Programming technique on the grounds that hiding the private data and making a public interface available means code can be reused. This black-box approach is much used in languages such as Java, SmallTalk and Objective-C.


Example code:

   var myLocalVariable;
   function myLocalFunction()
   export myLocalVariable;
   export myLocalFunction;

See also:import, Same origin, Signed scripts


ECMA 262 edition 2 - section - 7.4.3

ECMA 262 edition 3 - section - 7.5.3