This documentation is archived and is not being maintained.

interface Statement

Declares the name of an interface, as well as the properties and methods that comprise the interface.

[modifiers] interface interfacename [implements baseinterfaces] {


Optional. Modifiers that control the visibility and behavior of the property.


Required. The name of the interface; follows standard variable naming conventions.


Optional. Keyword indicating that the named interface implements, or adds members to, a previously defined interface. If this keyword is not used, a standard JScript base interface is created.


Optional. A comma-delimited list of interface names that are implemented by interfacename.


Optional. interfacemembers can be either method declarations (defined with the function statement) or property declarations (defined with the function get and function set statements).

The syntax for interface declarations in JScript is similar to that for class declarations. An interface is like a class in which every member is abstract; it can only contain property and method declarations without function bodies. An interface may not contain field declarations, initializer declarations, or nested class declarations. An interface can implement one or more interfaces by using the implements keyword.

A class may extend only one base class, but a class may implement many interfaces. Such implementation of multiple interfaces by a class allows for a form of multiple inheritance that is simpler than in other object-oriented languages, for example, in C++.

The following code shows how one implementation can be inherited by multiple interfaces.

interface IFormA {
   function displayName();

// Interface IFormB shares a member name with IFormA.
interface IFormB {
   function displayName();

// Class CForm implements both interfaces, but only one implementation of
// the method displayName is given, so it is shared by both interfaces and
// the class itself.
class CForm implements IFormA, IFormB {
   function displayName() {
      print("This the form name.");

// Three variables with different data types, all referencing the same class.
var c : CForm = new CForm();
var a : IFormA = c;
var b : IFormB = c;

// These do exactly the same thing.

The output of this program is:

This the form name.
This the form name.
This the form name.