PP.isInterfaceOf

Syntax

isInterfaceOf(obj, inter, throwEx: Boolean);

Parameters

obj. Class object to check.

inter. Interface or array of interfaces to be checked if they are implemented with the specified class.

throwEx. Indicates whether to throw an error if the class does not implement at least one interface. If this parameter is True an error is thrown if the class does not implement even one of the interfaces, if the parameter isFalse no error is thrown.

Description

The isInterfaceOf method checks if the given class implements specified interfaces.

Comments

The method returns True if the specified class implements the interfaces and False if otherwise.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Create an object of the PP.Ui.Button class and check it for implementation of the PP.Ui.IContentEditable and PP.IDataSource interfaces:

// Create a button
var button = new PP.Ui.Button({
    Width: 100,
    Height: 100
});
// Check if the button implements the PP.Ui.IContentEditable interface
var isInterfaceOf = PP.isInterfaceOf(button, PP.Ui.IContentEditable);
console.log("The PP.Ui.Button class " + (!isInterfaceOf ? "does not " : "") + "implements the PP.Ui.IContentEditable interface");
// Check if the button implements the PP.IDataSource interface
ckeckInterface = PP.isInterfaceOf(button, PP.IDataSource, False);
console.log("The PP.Ui.Button class " + (!ckeckInterface ? "does not " : "") + "implements the PP.IDataSource interface");

After executing the example the object of the PP.Ui.Button class is checked if it implements the PP.Ui.IContentEditable and PP.IDataSource interfaces. Check results are displayed to the browser console:

The PP.Ui.Button class implements the PP.Ui.IContentEditable interface
The PP.Ui.Button class does not implement the PP.IDataSource interface

See also:

PP