Defines a class using the given constructor and the specified instance members.
Syntax
var object = WinJS.Class.define(constructor, instanceMembers, staticMembers);
Parameters
- constructor
-
Type: Function
A constructor function that is used to instantiate this type.
- instanceMembers
-
Type: Object
The set of instance fields, properties, and methods made available on the type.
- staticMembers
-
The set of static fields, properties, and methods made available on the type.
Return value
Type: Object
The newly-defined type.
Remarks
For more information about using this method, see Defining and deriving types with WinJS.Class. For information about using constructors to define types in JavaScript, see Using Constructors to Define Types.
Examples
The following code shows how to use this method.
var Robot = WinJS.Class.define( function (name) { this.name = name; }, { modelName: "", on: function () { // Turn the robot on. }, off: function () { // Turn the robot off. } }, { harmsHumans: false, getModels: function () { // Return all the available models. } }); var myRobot = new Robot("Mickey"); myRobot.modelName = "4500"; myRobot.on(); Robot.harmsHumans = false; var models = Robot.getModels();
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
WinJS.Class |
|
Library |
|
Build date: 12/5/2012