WinJS.Namespace.define function

Applies to Windows and Windows Phone

Defines a new namespace with the specified name. For more information, see Organizing your code with WinJS.Namespace.

Syntax


var object = WinJS.Namespace.define(name, members);

Parameters

name

Type: string

The name of the namespace. This could be a dot-separated name for nested namespaces.

members

Type: object

The members of the new namespace.

Return value

Type: Object

The newly-defined namespace.

Examples

The following code shows how to use this function to define a Robotics namespace with a single Robot class.


WinJS.Namespace.define("Robotics", {
    Robot: WinJS.Class.define( function(name) {
            this.name = name;
        }, 
        { modelName: "" }, 
        { harmsHumans: false, obeysOrders: true })
});
var myRobot = new Robotics.Robot("Mickey");

myRobot.modelName = "4500";
var harm = Robotics.Robot.harmsHumans;

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1

Namespace

WinJS.Namespace

Library

Base.js

 

 

Show:
© 2014 Microsoft. All rights reserved.